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
相关推荐
苏三说技术30 分钟前
为什么越来越多人用 ZXing?
后端
Rain的Java大神之路32 分钟前
🔥13年Java老兵转型AI Agent:90%的人挂在同一个坑,根本不用学Python!(万字实战复盘,建议收藏)
java·后端·面试
yuniko-n32 分钟前
【Java】关于容器选型:Deque、PriorityQueue、LinkedList
java·开发语言
扶风ff33 分钟前
练题簿在线免费刷题:创建个人任务,把刷题、听题和模考目标放到每天的学习中
开发语言·javascript·学习·小程序
恋喵大鲤鱼33 分钟前
Rust str 与 String 类型的区别
rust
IT小番茄34 分钟前
用Codex搭可视化大屏工作流 15个行业场景设计稿看完直接抄作业
后端
by————组态35 分钟前
Ricon组态适用领域全景解析:工业制造、能源、市政民生与智慧城市四大场景落地实践
后端·物联网·数学建模·智慧城市·能源·制造·组态
花卷持续成长36 分钟前
什么是代理Bean?
后端