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
相关推荐
m0_3807438724 分钟前
PHP 8.4的新语法怎么用才规范
开发语言·php
阿狗童鞋36 分钟前
Java并发编程实战指南
java·开发语言
子兮曰1 小时前
Node.js 50个优势场景盘点:一个人单干,为啥我多数时候只用它
前端·后端
phltxy1 小时前
C 语言自定义类型:结构体、位段、枚举与联合体
c语言·开发语言
IT_陈寒1 小时前
我花3小时debug,就因为JavaScript这个隐式转换坑
前端·人工智能·后端
程序猿阿越1 小时前
containerd如何拉取镜像
后端·kubernetes·源码阅读
一条小小yu1 小时前
为什么使用springboot
java·spring boot·后端
Sarvartha1 小时前
对象创建与引用
java·开发语言
香瓜子rd2 小时前
MySQL InnoDB 并发控制核心原理:事务、隔离级别、MVCC 与锁机制
数据库·后端
RISCV_Explorer2 小时前
RISC-V RVV向量编程模型机制解析——vsetvl配置、掩码与尾元素策略及长度无关编程
后端·risc-v