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
相关推荐
特立独行的猫A6 小时前
用仓颉语言 cj-tauri 框架,五分钟给娃做了个鸿蒙形近字游戏
java·后端·python
码事漫谈9 小时前
我花了一周时间,看AI公司怎么"管"AI,结果越看越后背发凉
后端
大可不必了10 小时前
03 函数定义和调用
开发语言·python
I_belong_to_jesus10 小时前
C++关于分支预测的优化1
开发语言·c++·算法
承渊政道11 小时前
【Python编程—从入门到实践】(记分与闯关:用Python+Pygame,打造越战越精彩的太空大战!)
开发语言·python·pycharm·游戏程序·pygame
爱学习的程序媛11 小时前
Python常用框架梳理
开发语言·后端·python·ai·web·后端框架·python框架
GISer_Jing12 小时前
Agent核心内容
后端·ai·langchain
budingxiaomoli13 小时前
Spring统一功能处理
java·后端·spring
eggwyw13 小时前
Anaconda安装卸载的详细流程指南
开发语言·python
某鹏13 小时前
网关选型:Go、Java、Graal 谁都不能完胜
后端