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
相关推荐
Casual3 分钟前
【网络基础进阶】:看懂子网划分与 VLAN
开发语言·网络·php
LucianaiB4 分钟前
用 WorkBuddy 研究腾讯、阿里和 DeepSeek,我没敢直接说「AI 很赚钱」
后端
用户83562907805123 分钟前
使用 Python 管理 PDF 属性和元数据
后端·python
分支预测失败37 分钟前
RISC-V 上下文切换实战:从 Trap 入口到 Linux 进程调度
后端·嵌入式
cfm_29141 小时前
线程池阻塞队列
java·开发语言
用户8356290780511 小时前
使用 Python 在 Word 文档中创建自定义图表
后端·python
xxwxx__1 小时前
C++ list 深度解析:从使用原理到模拟实现
开发语言·c++·list
Chester_19991 小时前
CSP202303C.LDAP
开发语言·c++·蓝桥杯·stl
Profile排查笔记1 小时前
JavaScript 实现浏览器指纹生成:基础字段、Canvas 采样与 SHA-256 摘要
前端·人工智能·后端·自动化
奋斗吧程序媛2 小时前
CSV文件导入功能
开发语言·javascript·ecmascript