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
相关推荐
Nan_Shu_6147 小时前
学习: 尚硅谷Java项目之小谷充电宝(3)
java·后端·学习
智能工业品检测-奇妙智能7 小时前
AIFlowy如何实现与现有Spring Boot项目的无缝集成?
java·spring boot·后端
We་ct7 小时前
LeetCode 77. 组合:DFS回溯+剪枝,高效求解组合问题
开发语言·前端·算法·leetcode·typescript·深度优先·剪枝
格林威7 小时前
工业相机图像高速存储(C#版):内存映射文件方法,附Basler相机C#实战代码!
开发语言·人工智能·数码相机·c#·机器视觉·工业相机·堡盟相机
Nuopiane7 小时前
MyPal3(3)
java·开发语言
Ama_tor7 小时前
Flask零基础进阶(中)
后端·python·flask
lihihi7 小时前
P1650 [ICPC 2004 Shanghai R] 田忌赛马(同洛谷2587)
开发语言·算法·r语言
阿蒙Amon7 小时前
C#常用类库-详解Autofac
开发语言·c#
爱上妖精的尾巴7 小时前
8-18 WPS JS宏 正则表达式-边界匹配
开发语言·javascript·正则表达式·wps·jsa
人道领域7 小时前
苍穹外卖:菜品新增功能全流程解析
数据库·后端·状态模式