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
相关推荐
csbysj20203 小时前
jQuery 删除元素
开发语言
xxy-mm4 小时前
Javascript 中的继承
开发语言·javascript·ecmascript
锋行天下5 小时前
公司内网部署大模型的探索之路
前端·人工智能·后端
quikai19816 小时前
python练习第二组
开发语言·python
AI视觉网奇6 小时前
Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr
开发语言·c++·算法
wjs20246 小时前
并查集快速合并
开发语言
free-elcmacom6 小时前
MATLAB与高等数学<1>一道曲面积分题的几何直观
开发语言·数学建模·matlab·高等数学
LaoZhangGong1236 小时前
深度学习uip中的“psock.c和psock.h”
c语言·开发语言
Tony Bai6 小时前
Go 安全新提案:runtime/secret 能否终结密钥残留的噩梦?
java·开发语言·jvm·安全·golang
pengzhuofan6 小时前
Java演进与与工程师成长
java·开发语言