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
相关推荐
SamDeepThinking6 分钟前
我们当年是如何真实落地BFF的?
java·后端·架构
Asmewill13 分钟前
Centos系统docker时间同步方案
后端
阿正的梦工坊14 分钟前
【Rust】09-泛型、Trait 与生命周期基础
开发语言·rust·c#
用户83562907805123 分钟前
使用 Python 操作 Word 评论和回复
后端·python
心在飞扬34 分钟前
CentOS + Node.js 全套部署命令
后端
阿正的梦工坊37 分钟前
【Rust】07-错误处理:Option、Result 与 ? 运算符
开发语言·算法·rust
Zella折耳根41 分钟前
复习篇-继承和接口
java·开发语言·python
z落落1 小时前
C# 事件(Event)+自定义带参数事件例子
开发语言·分布式·c#
FlYFlOWERANDLEAF1 小时前
DevExpress Office File API使用记录
开发语言·c#·devoffice