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
相关推荐
Android洋芋12 小时前
AI辅助C盘清理
c语言·开发语言·人工智能·ai辅助c盘清理
humbinal13 小时前
同时支持 gui & cli 的 parquet 文件查看工具,高性能小清新!
hive·python·rust·spark·开源·github·parquet
wing9813 小时前
通往全干之路之:被迫成为全栈
前端·后端·程序员
灯澜忆梦13 小时前
Go 语言 _JSON---序列化与反序列化
开发语言·golang·json
云上小朱14 小时前
在k8s部署alist 3.62.0
后端
麻瓜老宋14 小时前
AI开发C语言应用按步走,表达式计算器calc的第四步,交互式 REPL 模式
c语言·开发语言·atomcode
花开彼岸天~14 小时前
鸿蒙原生开发手记:徒步迹 - 轨迹回放动画实现
后端
猫猫不是喵喵.14 小时前
双亲委派机制与类加载过程
java·开发语言
进击的前栈14 小时前
鸿蒙原生开发手记:徒步迹 - 文件读写与缓存管理
后端
布朗克16814 小时前
Go入门到精通-22-同步原语
开发语言·后端·golang·同步原语