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
相关推荐
汉字萌萌哒15 分钟前
2019CCF-CSP入门级C++试题解析
java·开发语言·c++
riverNijika18 分钟前
项目学习笔记:C++基础同步输出日志库
后端
叠层归一研究院20 分钟前
AGI 系统(十一):二阶网络 — 二阶递归 × 多主体 (元符号网络)
开发语言·人工智能·算法·php·agi
Lyra_Infra23 分钟前
OpenClaw 升级及 Channel 安装故障排查与遗留问题分析
后端·npm
江小渔29 分钟前
训练工程与训练平台入门 31 安装 Kubeflow Trainer,并跑第一个 TrainJob
后端
用户9385156350731 分钟前
从 0 拆解一个 Next.js 笔记系统:npx、App Router、RSC 与组件规划全记录
前端·后端·全栈
小雨笙笙33 分钟前
C语言:变量三属性——存储类型
c语言·开发语言
fatcoder1 小时前
玩转Docker 06 — 容器网络
前端·后端·docker
feng尘1 小时前
深入浅出 Java:ThreadLocal 为什么会产生内存泄漏?
后端
果果燕1 小时前
C++ 学习笔记(二):类与对象—— 构造函数与析构函数
开发语言·c++