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
相关推荐
上进小菜猪34 分钟前
把 KES 集群交给 Kubernetes 的九十天:一个 DBA 的试用实录
后端
两点王爷1 小时前
PostgreSQL 常用 SQL 语句与 GIS 相关函数详解
数据库·后端
考虑考虑2 小时前
Springboot环境变量占位符语法
spring boot·后端·spring
C++ 老炮儿的技术栈2 小时前
我们在设计tcp协议时,要传一个字符串过去,报文:头十长度十内容,是否要把‘\0‘也填入,长度是否包含‘\0‘
开发语言·数据结构·c++·mfc·c
传奇开心果编程3 小时前
【Rust入门练中学】第2课:变量、可变性与常量
开发语言·学习·rust
zr想努力3 小时前
从0开始配置Perforce4环境
开发语言
rustfs3 小时前
MinIO 国产开源平替正式 GA
分布式·docker·云原生·rust
步行cgn4 小时前
Spring 基于 XML 的自动装配:byName 详解
java·后端·spring
doiito4 小时前
【Agent Harness】Gliding Horse 最新进化:从“能学习”到“可验证的自主进化”
ai·rust·架构设计·ai agent
幸运小圣4 小时前
PointerEvent 常用属性与事件整理【JavaScript】
开发语言·javascript·ecmascript