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
相关推荐
驭渊的小故事5 分钟前
Spring AOP 入门:从 AOP 概念到第一个耗时统计切面
java·后端·spring
系统集成-鹰翔21 分钟前
ERP单据已作废为什么商品仍不能删除,引用检查与软删除怎么查
javascript·经验分享·后端
Moment24 分钟前
Harness Engineering 为什么是 AI Coding 的工程底座 ❓❓❓
前端·后端·面试
apcipot_rain1 小时前
C++转Java日记(05)
java·开发语言·c++
mldong1 小时前
主办先挂起,收齐意见再拍板:jeeflow 的动态会签
后端·架构
CQU_JIAKE9 小时前
11.7[高体】
java·后端·spring
Csvn9 小时前
认识 Nginx
后端·nginx
apcipot_rain10 小时前
C++转Java日记(04)
java·开发语言·c++
红尘散仙10 小时前
谁说终端只能敲键盘?我用 Rust 给小说阅读器加上了鼠标
前端·后端·rust
特立独行的猫A10 小时前
我给女儿写了个打字练习:一边敲键盘,一边把小学英语单词记牢
java·后端·python