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
相关推荐
wuyk555几秒前
98.C语言易混难点:字符数组与字符串指针的底层差异
c语言·开发语言·c++·stm32·嵌入式硬件·算法
峥无18 分钟前
从0到1手撕红黑树:封装实现 my_map 与 my_set(SGI-STL 源码级深度解析)
开发语言·c++·笔记·算法·stl
波特率11520021 分钟前
C++新特性---属性说明符与标准属性
开发语言·c++
程序员小八77725 分钟前
上海百度B端java后端日常实习一面
java·开发语言
北斗落凡尘36 分钟前
LangGraph 入门实战(11)--输出模式
后端·python·langchain
wp123_136 分钟前
IPX8 防水 Type‑C连接器:安费诺 124018792112A 与 TONEVEE TY48087‑24A 技术梳理
c语言·开发语言
不会代码的小猴1 小时前
3. 控件学习1
开发语言·c++·笔记·qt·算法
fangzhanpeng1681 小时前
(前端)2.js变量作用域样例
开发语言·前端·javascript
demo007x1 小时前
Hermes-Agent 技术架构
前端·后端·agent