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
相关推荐
程序员cxuan5 分钟前
Anthropic:session 之间可以相互通信了
人工智能·后端·程序员
周GZ18 分钟前
简单讲解Java中静态方法与 实例方法
java·开发语言
卷无止境27 分钟前
FastAPI 前端托管全攻略:从静态文件到大型全栈项目架构
后端·python
webmote3329 分钟前
用 NVIDIA Nemotron 3 Super + .NET 构建有记忆的多轮对话
后端·算法
神奇小汤圆33 分钟前
JUC三大常用工具类CountDownLatch、CyclicBarrier、Semaphore
后端
卷无止境1 小时前
当FastAPI项目开始"膨胀",代码该往哪儿放
后端·python
fliter1 小时前
程序员每天能省 1 小时的 50 个 macOS/终端/Git/浏览器技巧
后端
神奇小汤圆1 小时前
Redis为什么使用哈希槽而不用一致性哈希
后端
用户8356290780511 小时前
Python设置PowerPoint幻灯片背景的方法
后端·python
站大爷IP1 小时前
Python 的 is 把我坑惨了,原来 == 和 is 在小整数池外完全是两码事
后端