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
相关推荐
码事漫谈12 分钟前
token账单到底要怎么看
后端
Amumu1213824 分钟前
TypeScript学习: 基础知识(二)
开发语言·typescript·ecmascript
Cosolar1 小时前
当 Harness 标准化后,工程师还剩什么?
人工智能·后端·agent
sharemylove1 小时前
Java 异常与常用类 学习笔记
java·开发语言·经验分享·笔记·学习
小灰灰搞电子1 小时前
C 语言基础:动态内存管理详解
c语言·开发语言
打工仔折腾 AI1 小时前
L3 静态源码取证|工程评测:python-oracledb 驱动评估中的样本偏差陷阱
开发语言·人工智能·后端·python·性能优化
stark张宇2 小时前
分布式事务方案设计与选型思考:消息队列
后端
Amumu121382 小时前
TypeScript学习: 进阶知识
开发语言·学习·typescript
想不到一个好的ID3 小时前
什么是线程安全
后端
Dreams_l3 小时前
基于SpringBoot实现的抽奖系统(四)
java·spring boot·后端