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
相关推荐
vb2008115 分钟前
FastAPI APIRouter
开发语言·python
Benszen6 分钟前
KVM虚拟化解决方案
开发语言·perl
会编程的土豆8 分钟前
Go 语言反射(Reflection)详解
开发语言·后端·golang
東雪木10 分钟前
多线程与并发编程 专属复习笔记
java·开发语言·笔记·java面试
喵个咪28 分钟前
GoWind Toolkit Go后端代码生成 完整全流程实战
后端·go·orm
杨充42 分钟前
1.3 浮点型数据设计灵魂
开发语言·python·算法
噜噜噜阿鲁~1 小时前
python学习笔记 | 11.3、面向对象高级编程-多重继承
java·开发语言
basketball6161 小时前
Go 语言从入门到进阶:4. 数组和MAP使用方法总结
开发语言·后端·golang
qq_2518364571 小时前
SpringBoot+Vue 共享电池柜管理系统 完整实现 前后端分离项目实战 完整代码
vue.js·spring boot·后端
春生野草1 小时前
反射、Tomcat执行
java·开发语言