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
相关推荐
我是唐青枫7 分钟前
Java JCommander 实战详解:用注解解析命令行参数
java·开发语言
大鹏说大话15 分钟前
C++ 内存布局详解:类、虚函数、虚表底层原理
java·开发语言
仙人球部落 揞殺20 分钟前
细说ASP.NET的各种异步操作
后端·asp.net
键盘会跳舞27 分钟前
C++:容器适配器 queue 的源码级拆解
开发语言·c++·queue
kaixin_learn_qt_ing32 分钟前
了解Rust/Tauri
rust
Loge编程生活2 小时前
打卡信奥刷题(3449)用C++实现信奥题 P10429 [蓝桥杯 2024 省 B] 拔河
开发语言·数据结构·c++·算法·青少年编程
卷无止境2 小时前
当独立开发者也能造出3A画质的游戏:Godot引擎深度解析
后端·python·godot
在世修行2 小时前
从零打造 C# 工业视觉检测系统(八):Modbus RTU 协议解析与 PLC 剔除控制实战
开发语言·c#
doiito2 小时前
【Agent Harness】Gliding Horse 最新升级:把“智能闭环”真正跑通的一次深度优化
rust·架构设计·系统设计·ai agent
sunburn-3 小时前
Java 队列全面详解:从入门到面试实战
java·开发语言·汇编·ide·idea