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
相关推荐
神仙别闹几秒前
基于Python实现英词语自动对齐系统
开发语言·python
akinggw7 分钟前
libagentcore - 一个基于c++的AI多agent系统升级到2.0版本
开发语言·jvm·c++
苍何16 分钟前
DeepSeek的Super-agent 设计,和我们的工程实践
后端
Patrick_Wilson36 分钟前
第一次读 Go 项目:从两个源码文件弄清 package、import 和 go.mod
后端·go·编程语言
Patrick_Wilson38 分钟前
执行 go build . 后,Go 怎样找到代码并生成程序
后端·go·编程语言
用户69190268133940 分钟前
Redis 2:Redis 在怎么处理harness记忆
后端
老歌老听老掉牙40 分钟前
圆柱端面四平面交线及其在yoz面投影的几何解析与 Python 实现
开发语言·python·平面
Patrick_Wilson43 分钟前
Go 变量不赋值时,为什么也有值
后端·go·编程语言
Patrick_Wilson43 分钟前
读 Go 项目里的命令:run、build、test 分别做了什么
后端·go·编程语言
旖旎夜光1 小时前
【C++ 基础入门】命名空间、输入输出、缺省参数与函数重载
开发语言·c++·笔记·学习