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
相关推荐
t***5445 小时前
如何配置Orwell Dev-C++使用Clang
开发语言·c++
CoderCodingNo6 小时前
【信奥业余科普】C++ 的奇妙之旅 | 13:为什么 0.1+0.2≠0.3?——解密“爆int”溢出与浮点数精度的底层原理
开发语言·c++
杨凯凡6 小时前
【021】反射与注解:Spring 里背后的影子
java·后端·spring
Ares-Wang6 小时前
Flask》》 Flask-Bcrypt 哈希加密
后端·python·flask
小码哥_常7 小时前
Spring Boot项目大变身:为何要拆成这六大模块?
后端
kongba0077 小时前
项目打包 Python Flask 项目发布与打包专家 提示词V1.0
开发语言·python·flask
froginwe117 小时前
C 语言测验
开发语言
今夕资源网8 小时前
powershell工具包 安装升级脚本并设置UTF-8 环境快捷方式创建 将powershell的编码默认改为UTF-8
开发语言·utf-8·powershell·utf-8编码·powershell7·powershell5·设置utf-8编码
机器视觉知识推荐、就业指导8 小时前
Qt:真正的门槛不是入门,而是维护
开发语言·qt
hhb_6188 小时前
Dylan 语言核心特性与工程实践深度解析
开发语言·c#