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
相关推荐
摇滚侠12 分钟前
SpringBoot 官网 阅读笔记 启用生产就绪功能 端点
spring boot·笔记·后端
用户昵称10016 分钟前
C/C++编程-工程实践-本地存储log的工程意义
c语言·开发语言
我命由我123451 小时前
匈牙利命名法
java·服务器·后端·学习·java-ee·kotlin·学习方法
吹什么轩1 小时前
c++复习:map和set的使用
开发语言·c++
苏三说技术1 小时前
一线大厂的Git规范
后端
必须得开心呀2 小时前
qt生成dump文件并定位异常
开发语言·qt
神奇小汤圆2 小时前
阿里面试官问我:“Redis 的 String 底层是怎么设计的?”,我画完 SDS,他点了点头……
后端
fpcc2 小时前
跟我学C++中级篇—内存流
开发语言·c++
魔镜前的帅比2 小时前
(开源项目)x-claw (设计)
python·ai·rust·开源