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
相关推荐
剩下了什么14 分钟前
float32 与 float64 精度陷阱:如何在 Go 中避免错误使用
开发语言·后端·golang
Rain的Java大神之路21 分钟前
介绍一下分布式事务
java·分布式·后端·spring·spring cloud·架构·springcloud
指尖时光.27 分钟前
Three.js 超全入门综合案例
开发语言·javascript·ecmascript
暴力求解1 小时前
Linux网络---传输层协议TCP(二)
linux·服务器·开发语言·网络·tcp/ip
吴声子夜歌1 小时前
Java面试题——基础(一)
java·开发语言
小庞在加油1 小时前
WinDbg实战:QT/跨平台项目死锁与无响应问题排查指南
开发语言·qt·windbg·工具
Vae_Mars2 小时前
C#中的delegate委托
开发语言·c#
一直走下去-明2 小时前
简单的http抓包解包完整代码
开发语言·python
caimouse3 小时前
ReactOS 图形系统分析(51):元文件子系统 — metafile.c
c语言·开发语言
学习星球4 小时前
Solid.js 实战:拆解官方 RealWorld 项目
开发语言·javascript·vue.js