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
相关推荐
云天徽上17 小时前
【数据可视化-106】华为2025上半年财报分析:用Python和Pyecharts打造炫酷可视化大屏
开发语言·python·华为·信息可视化·数据分析·pyecharts
尘鹄20 小时前
go 初始化组件最佳实践
后端·设计模式·golang
墩墩分墩20 小时前
【Go语言入门教程】 Go语言的起源与技术特点:从诞生到现代编程利器(一)
开发语言·后端·golang·go
CHANG_THE_WORLD20 小时前
并发编程指南 同步操作与强制排序
开发语言·c++·算法
仰泳之鹅20 小时前
【C语言】深入理解指针(5)
c语言·开发语言
无为之士1 天前
君正交叉编译链工具mips-gcc540-glibc222-64bit-r3.3.0.smaller.bz2编译st-device-sdk-c
c语言·开发语言
程序员爱钓鱼1 天前
Go语言实战案例- 开发一个ToDo命令行工具
后端·google·go
源力祁老师1 天前
深入分析 json2(新)与标准的 jsonrpc的区别
开发语言
小wanga1 天前
C++知识
java·开发语言·c++