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
相关推荐
Csvn2 小时前
安装、升级与目录结构
后端·nginx
皮皮林5512 小时前
万能通用!权限系统就该这么设计
后端
GoAI4 小时前
DeepSeek Harness Memory (一)主流记忆插件总结
后端·算法·面试
czq_26867194874 小时前
Python打卡第46天
开发语言·python
橙子家4 小时前
RESTful 接口:它并非标准或协议,而是一种【架构风格】
后端
小兔子5 小时前
dict.get 的默认值每次都会求值,哪怕键本来就在
后端
斯维赤5 小时前
限流、熔断、降级,你真的分得清吗?
java·后端·架构
肌肉娃子5 小时前
红队攻防测试报告 — wechat-e.cfd
后端
陈随易5 小时前
Cmder 停更 17 个月,2.0 支持 Windows Terminal
前端·后端·程序员
海螺_AIHCC5 小时前
SSE 流式返回中文变问号,问题不在编码
后端