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
相关推荐
Wang's Blog1 小时前
Go-Zero项目开发4: 用户服务搜索、详情与统一错误处理
开发语言·golang
我星期八休息2 小时前
网络编程—应用层HTTP协议
linux·运维·开发语言·前端·网络·网络协议·http
梅雅达编程笔记2 小时前
零基础学 Python 第14章 | 模块、包与第三方库
开发语言·python·django·numpy·pandas
Mr__Miss2 小时前
Java泛型完全指南:从入门到精通
java·开发语言·python
赵庆明老师2 小时前
Vben精讲:14-Vben远程加载语言包
开发语言·vben
hehelm3 小时前
AI大模型接入SDK—通用模块设计
linux·开发语言·c++
前端工作日常3 小时前
我学习到的Java类和对象区别
java·后端
前端工作日常4 小时前
我学习到的Java类完整结构
java·后端
Csvn4 小时前
📊 SQL 入门 Day 6:多表查询 — JOIN 的四种姿势
后端·sql
梅雅达编程笔记5 小时前
零基础学 Python 第15章 | 类与对象:面向对象编程入门
开发语言·python·django·numpy·pandas