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
相关推荐
ghie90904 分钟前
基于MATLAB的TLBO算法优化实现与改进
开发语言·算法·matlab
恋爱绝缘体14 分钟前
2020重学C++重构你的C++知识体系
java·开发语言·c++·算法·junit
wuk9984 分钟前
VSC优化算法MATLAB实现
开发语言·算法·matlab
AI小怪兽23 分钟前
基于YOLOv13的汽车零件分割系统(Python源码+数据集+Pyside6界面)
开发语言·python·yolo·无人机
Z1Jxxx36 分钟前
加密算法加密算法
开发语言·c++·算法
Eric.Lee202144 分钟前
python实现 mp4转gif文件
开发语言·python·手势识别·手势交互·手势建模·xr混合现实
EntyIU1 小时前
python开发中虚拟环境配置
开发语言·python
踏浪无痕1 小时前
AI 时代架构师如何有效成长?
人工智能·后端·架构
程序员小假2 小时前
我们来说一下无锁队列 Disruptor 的原理
java·后端
charlie1145141912 小时前
嵌入式现代C++教程: 构造函数优化:初始化列表 vs 成员赋值
开发语言·c++·笔记·学习·嵌入式·现代c++