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
相关推荐
mldong13 小时前
换审批人不用写代码:jeeflow工作流引擎内置 9 种找人规则
后端·架构
Moment13 小时前
27B 的本地模型也能做知识图谱?太强了!😍😍😍
前端·后端·面试
码事漫谈1 天前
AI正在攻破你的密码
后端
皮皮林5511 天前
一款开源强大的数据同步神器,主流数据库全支持!
后端
FRing031 天前
vue2干货总结12(loading效果、全局前置导航守卫、搜索历史管理)
开发语言·前端·javascript·vue.js·vue2
wefg11 天前
【项目】C++ 基于 Vibe Coding 的 OJ 平台
开发语言·c++
喵个咪1 天前
GoWind Trade(风帆):从询盘到收款的外贸全流程一体化平台
后端·架构·go
喵个咪1 天前
GoWind Ops:开箱即用的多节点运维平台——管机器、跑项目、发脚本、构建分发
后端·go·自动化运维
喵个咪1 天前
GoWind IM 私有化快速部署:研发型企业自己的协同底座
后端·架构·go
喵个咪1 天前
GoWind IoT(风行物联网):从设备接入到告警运维的设备管理平台
后端·物联网·go