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
相关推荐
IT_陈寒39 分钟前
Redis雪崩把我坑惨了,这是5年经验的教训
前端·人工智能·后端
量化分析码农42 分钟前
【Python量化多因子实战 06】从因子到持仓:多因子选股实盘工程化落地
后端
心祭丫丫1 小时前
【每天一个 Python 小案例17】Python 实现通讯录
开发语言·人工智能·笔记·python·学习
贾公子1 小时前
检测链路的容量规划——用 Little's Law 算清 QPS、并发与积压
后端·python
kyson_1 小时前
Java 集合框架:从继承体系到数据结构,再到开发选型
后端
露天赏雪1 小时前
第3篇:Sentinel熔断降级实战:大模型接口抖动时的服务兜底方案
java·开发语言·人工智能·spring boot·spring·servlet·sentinel
想不到一个好的ID2 小时前
什么是RAG
后端
金銀銅鐵2 小时前
JDK 21 中 List.of 的实现细节:从 List12 到 ListN
java·后端·ai编程
苏三说技术2 小时前
Codex中必装的11个Skills
后端
付威20233 小时前
target 目录越来越大,Rust 项目该怎么清理
后端