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
相关推荐
可夫小子2 小时前
AI 写了 200 万行 Rust 克隆闭源二进制分析软件,软件保护的旧防线还稳吗
rust
特立独行的猫A7 小时前
DDS 调试助手:用仓颉写的跨厂商 DDS 抓包与监控工具(开源)
后端
码事漫谈8 小时前
OPC到底是什么:一年冒出1600万家,九成活不过2026年
后端
陆枫Larry8 小时前
从一个 Java Demo 聊聊 H2 数据库的前世今生
后端
特立独行的猫A8 小时前
仓颉版 Tauri 单文件 exe:gcc -r 一招破解 GCC-LTO 静态库链接
后端
金銀銅鐵8 小时前
带您看懂字节码指令(番外二):递归里有什么——三层 fact 帧怎么叠起来
java·jvm·后端
皮皮林5519 小时前
私活神器,腾讯低代码平台开源了,拖拽就能开发~
后端
两点王爷11 小时前
Java 面试高频:JWT、Cookie、Session、Token 鉴权详解
java·开发语言·面试
用户1129361121912 小时前
npm 都提示成功了,node_modules 为什么还占着 370M?
linux·前端·后端