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
相关推荐
Python+998 分钟前
Java 枚举类(Enum)详解:从基础到高级应用
java·开发语言·python
二炮手亮子32 分钟前
浅记java线程池
java·开发语言
zmzb01031 小时前
C++课后习题训练记录Day157
开发语言·c++
dunge20261 小时前
2026年7月最新ChatGPT Plus / Pro 与 Codex:当 AI Agent 最新5.6版本来袭,必须理解事务、幂等与补偿
开发语言·人工智能·python
Dovis(誓平步青云)1 小时前
远程办公软件文件传输实测:6 款工具的速度、稳定性和办公体验对比
linux·运维·服务器·后端·生成对抗网络
凌虚2 小时前
AI 时代,程序员会消失吗?
人工智能·后端·程序员
爱吃牛肉的大老虎2 小时前
rust基础之环境搭建
java·开发语言·rust
openKylin2 小时前
与全球技术演进同频,openKylin 3.0从C迈向Rust
c语言·开发语言·rust·开源·开放原子·openkylin
用户8356290780513 小时前
使用 Python 在 Excel 中添加和自定义文本框
后端·python