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
相关推荐
chouchuang15 分钟前
day-027-面向对象-下
开发语言·python
誰能久伴不乏17 分钟前
C++11 随机数生成——告别 rand()
开发语言·c++
海清河晏11120 分钟前
数据结构 | 二叉平衡搜索树
开发语言·数据结构·visual studio
用户67570498850222 分钟前
手摸手教你玩 Jenkins,一次搞懂 CI/CD!(第二章:发布之sshPublisher)
后端·jenkins
用户67570498850229 分钟前
手摸手教你玩 Jenkins,一次搞懂 CI/CD!(第一章:部署)
后端·jenkins
kuonyuma31 分钟前
java之动态代理
java·开发语言
KouFiee37 分钟前
同名隐藏基础
开发语言·c++
一路向北North42 分钟前
Spring Security OAuth2.0(20):完善环境配置
java·后端·spring
z落落1 小时前
C# Task WaitAll、WaitAny、WhenAll、WhenAny
开发语言·c#
兰令水1 小时前
hot100【acm版】【2026.7.11/12打卡-java版本】
java·开发语言·数据结构·算法·职场和发展