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
相关推荐
lbb 小魔仙12 分钟前
【Java】Spring Data JPA 详解:ORM 映射、查询方法与复杂 SQL 处理
java·开发语言·sql·spring cloud
Fighting_p34 分钟前
【预览word文档】使用插件 docx-preview 预览线上 word 文档
开发语言·c#·word
superman超哥43 分钟前
Rust 发布 Crate 到 Crates.io:从本地到生态的完整旅程
开发语言·后端·rust·crate·crates.io
浪客川43 分钟前
【百例RUST - 002】流程控制 基础语法练习题
开发语言·rust
一路往蓝-Anbo1 小时前
C语言从句柄到对象 (二) —— 极致的封装:不透明指针与 SDK 级设计
c语言·开发语言·数据结构·stm32·单片机·嵌入式硬件
上天_去_做颗惺星 EVE_BLUE1 小时前
C++学习:学生成绩管理系统
c语言·开发语言·数据结构·c++·学习
雪域迷影1 小时前
使用Python库获取网页时报HTTP 403错误(禁止访问)的解决办法
开发语言·python·http·beautifulsoup·urllib
chao1898441 小时前
基于Qt的SSH/FTP远程文件管理与命令执行实现方案
开发语言·qt·ssh
凯子坚持 c1 小时前
Qt常用控件指南(1)
开发语言·数据库·qt
Flash.kkl1 小时前
Python基础语法
开发语言·python