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
相关推荐
yqcoder2 分钟前
JavaScript 内存揭秘:堆(Heap) vs 栈(Stack)
开发语言·javascript·ecmascript
覆东流3 分钟前
第11天:python字典基础
开发语言·后端·python
河阿里5 分钟前
深入理解LRU缓存机制:从原理到应用(C++实现
开发语言·c++·缓存
xyq20247 分钟前
PHP Date
开发语言
杨充14 分钟前
03.计算机基础CPU设计
java·开发语言
gergul18 分钟前
python venv虚拟环境复制
linux·开发语言·python
LNN202219 分钟前
半导体设备上位机 Qt 实现计划
开发语言·数据库·qt
摇滚侠20 分钟前
Java 项目教程《黑马商城》OpenFeign 15 - 19
java·开发语言
摇滚侠24 分钟前
Java 项目教程《黑马商城》微服务拆分 05 - 10
java·开发语言·微服务
IT_陈寒24 分钟前
JavaScript实战技巧总结
前端·人工智能·后端