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
相关推荐
RPGMZ18 小时前
RPGMakerMZ 地图存档点制作 标题继续游戏直接读取存档
开发语言·javascript·游戏·游戏引擎·rpgmz·rpgmakermz
丑八怪大丑19 小时前
JDK8-17新特性
java·开发语言
书源丶19 小时前
三十五、Java 泛型——类型安全的「万能模板」
java·开发语言·安全
EF@蛐蛐堂19 小时前
【js】浏览器滚动条优化组件OverlayScrollbars
开发语言·javascript·ecmascript
dovens19 小时前
SpringBoot集成MQTT客户端
java·spring boot·后端
❀͜͡傀儡师19 小时前
Spring Boot 集成 RocksDB 实战:打造高性能 KV 存储加速层
java·spring boot·后端·rocksdb
TeamDev19 小时前
如何在 DotNetBrowser 中使用本地 AI 模型
前端·后端·.net
代码中介商19 小时前
C++ 仿函数(Functor)深度解析:从基础到应用
开发语言·c++
小杍随笔20 小时前
Rust桌面GUI框架:性能优化与实战避坑指南
开发语言·性能优化·rust