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
相关推荐
曹轲恒4 小时前
Java中断
java·开发语言
施棠海4 小时前
监听与回调的三个demo
java·开发语言
時肆4854 小时前
C语言造轮子大赛:从零构建核心组件
c语言·开发语言
赴前尘5 小时前
golang 查看指定版本库所依赖库的版本
开发语言·后端·golang
de之梦-御风5 小时前
【C#.Net】C#开发的未来前景
开发语言·c#·.net
知乎的哥廷根数学学派5 小时前
基于数据驱动的自适应正交小波基优化算法(Python)
开发语言·网络·人工智能·pytorch·python·深度学习·算法
de之梦-御风5 小时前
【C#.Net】C#在工业领域的具体应用场景
开发语言·c#·.net
sunfove5 小时前
将 Python 仿真工具部署并嵌入个人博客
开发语言·数据库·python
Learner6 小时前
Python类
开发语言·python
X1A0RAN7 小时前
python 借助 paramiko 库执行 SSH命令报错:input is not a terminal 解决方式
开发语言·python·ssh