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
相关推荐
瑞码空间12 小时前
Python爬虫进阶实战笔记
开发语言·python·计算机·python爬虫
掘金者阿豪12 小时前
时序数据库选型被写入峰值带偏了?金仓超表让我少加了不少班
后端
16月6日-晴12 小时前
Java面向对象进阶—static
java·开发语言
爱跳舞的烤冷面12 小时前
自学嵌入式第16天(数据结构篇--链表进阶操作)
开发语言
持敬chijing13 小时前
PHP开发-环境搭建-安装phpstudy-vscode工具
开发语言·vscode·php
大黄评测13 小时前
jQuery 遍历方法 each 实战:循环处理列表数据
后端
大勇前进13 小时前
jQuery 事件委托原理:彻底解决动态生成元素绑定失效问题
后端
苍何13 小时前
做了个微信聊天爆款视频 Skill, Codex / WorkBuddy一键复刻使用
后端·aigc
卷无止境13 小时前
用 FastAPI 撑起大文件的上传下载:从流式处理到断点续传的完整实践
后端·python·fastapi
铁皮饭盒13 小时前
网页端, 6.5MB人脸识别模型, 谷歌框架, 又快又准
前端·javascript·后端