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
相关推荐
喜欢吃燃面35 分钟前
C++:哈希表
开发语言·c++·学习
mit6.82435 分钟前
[C++] 时间处理库函数 | `tm`、`mktime` 和 `localtime`
开发语言·c++
SweetCode36 分钟前
C++ 大数乘法
开发语言·c++
bobogift43 分钟前
【玩转全栈】----Django基本配置和介绍
java·后端
listhi5201 小时前
基于空时阵列最佳旋转角度的卫星导航抗干扰信号处理的完整MATLAB仿真
开发语言·matlab·信号处理
倚栏听风雨1 小时前
Async-Profiler 框架简介
后端
lly2024061 小时前
Kotlin 类和对象
开发语言
是苏浙1 小时前
零基础入门C语言之C语言内存函数
c语言·开发语言
qianbailiulimeng1 小时前
2019阿里java面试题(一)
java·后端
zhmhbest1 小时前
Qt 全球峰会 2025:中国站速递 —— 技术中立,拥抱更大生态
开发语言·qt·系统架构