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
相关推荐
梨子同志13 小时前
开发工具
前端·后端
梨子同志13 小时前
Java
后端
像我这样帅的人丶你还13 小时前
Java 后端详解(六):Maven 与本地开发指南
前端·后端
tonydf13 小时前
.NET 项目集成可观测性:从架构思考到落地实践
运维·后端
梨子同志13 小时前
PostgreSQL
后端
༄沐࿆风࿆࿆13 小时前
JavaScript函数完全指南:从基础语法到闭包原理与应用实战
开发语言·javascript
KobeSacre14 小时前
DelayQueue 源码
java·开发语言
AskHarries14 小时前
用 OpenClaw 做视频脚本:选题、分镜、旁白和镜头表
后端·程序员
han_hanker14 小时前
重新认识枚举enum
开发语言
狂炫冰美式14 小时前
凌晨睡不着,我给台风巴威写了个追踪网站
前端·后端·github