Rust Pin

Rust Pin

(Jin Qing's Column, Sep., 2024)

From: https://doc.rust-lang.org/std/pin/index.html

Rust can pin data location in memory, that means its address can not be changed.

Pinned data guarantees the memory location is always valid.

Safe code can not move pinned data to another location.

Safe code users do not need to care about Pin.

  • What's moving
    • copy + ownership
    • all values are movable
      • assignment or function parameter
      • mem::replace
  • What's pinning
    • until drop
  • Address sensitivity
    • some interface is relay on pinned state
    • self-referenced type: Future
    • leverage the type system
      • Pin
    • how Pin works
      • restrict access to Ptr
    • PhantomPinned
  • Example types
    • self-referential struct
    • intrusive list
  • Drop
  • Projection and Structural Pinning
相关推荐
程序员cxuan17 分钟前
Pi + DeepSeek-v4-Flash,这用着也太爽了。
人工智能·后端·程序员
进击的程序猿~24 分钟前
Go Interface源码深度解析指南
开发语言·后端·golang
Data_Journal41 分钟前
如何使用 Java 和 Jsoup 解析 HTML
大数据·开发语言·数据库·python·scrapy
吃好睡好便好1 小时前
MATLAB仿真框图2
开发语言·matlab·仿真·simulink
qo_tn1 小时前
微信机器人-webhook技术文档_04-Docker-Compose部署与生产化配置
后端
程序员cxuan1 小时前
Claude Opus 5 的系统提示词被扒出来了
人工智能·后端·程序员
董员外1 小时前
RAG 系统进化论(十):可运营 RAG,从原型到长期运行的知识系统
人工智能·后端·设计模式
newerp1 小时前
贪心算法 — 局部最优推导全局最优
后端
Embedded-Xin1 小时前
中间件—zenoh零基础入门
linux·中间件·rust·机器人·自动驾驶·嵌入式
掘金者阿豪2 小时前
SQL Server数据迁移实践:KES V9R4C019如何解决兼容性、性能与运维挑战
后端