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
相关推荐
hbqjzx8 小时前
记录一个自动学习的脚本开发过程
开发语言·javascript·学习
zl9798998 小时前
SpringBoot-依赖管理和自动配置
spring boot·后端·状态模式
JaguarJack8 小时前
PHP8.5 的新 URI 扩展
后端·php
绝无仅有8 小时前
面试真实经历某商银行大厂数据库MYSQL问题和答案总结(一)
后端·面试·github
绝无仅有8 小时前
Docker 实战经验之关键文件误删恢复指南
后端·面试·github
Sirens.8 小时前
Java核心概念:抽象类、接口、Object类深度剖析
java·开发语言·github
QZQ541888 小时前
go中reflect的底层原理
后端
白衣鸽子8 小时前
CAP理论:分布式系统的“不可能三角”
后端·架构
焰火19998 小时前
[Java]基于Spring的轻量级定时任务动态管理框架
java·后端
程序员阿鹏8 小时前
49.字母异位词分组
java·开发语言·leetcode