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
相关推荐
百万蹄蹄向前冲1 小时前
Trae Genimi3跟着官网学实时通信 Socket.io框架
前端·后端·websocket
狂炫冰美式2 小时前
TRAE SOLO 驱动:重构AI模拟面试产品的复盘
前端·后端·面试
x***38164 小时前
springboot和springframework版本依赖关系
java·spring boot·后端
故事不长丨4 小时前
C#定时器与延时操作的使用
开发语言·c#·.net·线程·定时器·winform
hefaxiang4 小时前
C语言常见概念(下)
c语言·开发语言
欧阳天风4 小时前
js实现鼠标横向滚动
开发语言·前端·javascript
yue0085 小时前
C# Directory的用法介绍
开发语言·c#
韩立学长5 小时前
基于Springboot课堂教学辅助系统08922bq1(程序、源码、数据库、调试部署方案及开发环境)系统界面展示及获取方式置于文档末尾,可供参考。
数据库·spring boot·后端
雨落秋垣5 小时前
手搓 Java 的用户行为跟踪系统
java·开发语言·linq
盖世英雄酱581365 小时前
java深度调试技术【第六七八章:宽字节与多字节】
java·后端