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
相关推荐
x***J34813 分钟前
Python多线程爬虫
开发语言·爬虫·python
TechTrek15 分钟前
Spring Boot 4.0正式发布了
java·spring boot·后端·spring boot 4.0
m***D28619 分钟前
Python网络爬虫实战案例
开发语言·爬虫·python
保持低旋律节奏29 分钟前
C++——C++11特性
开发语言·c++·windows
飞梦工作室34 分钟前
企业级 Spring Boot 邮件系统开发指南:从基础到高可用架构设计
java·spring boot·后端
haiyu柠檬37 分钟前
在Spring Boot中实现Azure的SSO+VUE3前端配置
java·spring boot·后端
ID_180079054731 小时前
基于 Python 的淘宝商品详情数据结构化解析:SKU、价格与库存字段提取
开发语言·数据结构·python
q***72191 小时前
springBoot 和springCloud 版本对应关系
spring boot·后端·spring cloud
星释1 小时前
Rust 练习册 82:Hamming与字符串处理
开发语言·算法·rust
时间不说谎1 小时前
c/c++的语法糖
开发语言