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
相关推荐
独泪了无痕21 小时前
探索Pinyin4j-Java中的拼音转换利器
java·后端
码事漫谈21 小时前
从 Coze 居然要下线了说起
后端
想不到一个好的ID1 天前
智能体开发
后端
皮皮林5511 天前
为什么数据库连接池不采用 IO 多路复用?
后端
来让爷抱一个1 天前
Python 异步里混用同步库,事件循环被卡住的全过程
开发语言·python
IT_陈寒1 天前
Redis雪崩把我坑惨了,这是5年经验的教训
前端·人工智能·后端
量化分析码农1 天前
【Python量化多因子实战 06】从因子到持仓:多因子选股实盘工程化落地
后端
心祭丫丫1 天前
【每天一个 Python 小案例17】Python 实现通讯录
开发语言·人工智能·笔记·python·学习
贾公子1 天前
检测链路的容量规划——用 Little's Law 算清 QPS、并发与积压
后端·python
kyson_1 天前
Java 集合框架:从继承体系到数据结构,再到开发选型
后端