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
相关推荐
程序员cxuan9 分钟前
玩了一天 REA,我号快没了
人工智能·后端·程序员
卷无止境18 分钟前
暗流与破局:AI时代的代码安全审查工具全景指南
后端·python
smallyoung34 分钟前
告别N+1:Spring Boot 一键数据翻译框架体系
java·后端·架构
程序猿DD1 小时前
OctaFuse Gateway 2.16.0:新增 ElevenLabs 的支持、厂商原生端点重构、后台管理优化
后端
掘金者阿豪1 小时前
列存储适不适合订单报表?从一条慢 SQL 聊聊金仓 KES 的使用边界
后端
武子康1 小时前
150毫秒和2400毫秒:同一 Agent 任务的两种延迟
人工智能·后端·agent
海边捡石子2 小时前
FreeSWITCH 入门:把电话系统接入语音客服机器人
人工智能·后端
武子康2 小时前
Agent 偏好记忆怎样确认写入:范围、版本与撤销的一个最小例
人工智能·后端·agent
Bazingga2 小时前
Java16 record 完整拆解——语法、语义、限制、反射
java·后端
对象存储与RustFS2 小时前
网盘限速逼你开会员?用 RustFS 自己搭一个不限速的“私人网盘
服务器·后端·docker