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
相关推荐
C语言小火车9 小时前
C++ 为什么越来越依赖标准库?
java·开发语言·c++
郝学胜-神的一滴9 小时前
金融数据分析实战:从数据清洗到策略回测,Python全链路落地
开发语言·python·程序人生·金融·数据挖掘·数据分析
woniu_maggie9 小时前
SAP 主数据 MDM 与MDG分析
后端
9 小时前
正则少一个 re.MULTILINE,我的安全闸门全程空转——而我以为修好了
后端·代码规范
柠檬味拥抱9 小时前
脑肿瘤检测数据集 | 4400张YOLO医学影像数据集
后端
冒险的豆子10 小时前
JS 原型链 通俗易懂 解释说明(类比 关系)
开发语言·javascript·原型模式
破茧蝴蝶10 小时前
Selenium4 Python 页面白屏监控方案
开发语言·python
柠檬味拥抱10 小时前
汽车损伤检测数据集 | 11700张YOLO车辆定损数据集
后端
柠檬味拥抱10 小时前
基于 YOLO11 的规模化禽舍鸡只行为视觉监测平台:从模型到 Streamlit 全流程实战
后端
柠檬味拥抱10 小时前
火灾智能检测预警系统:从 YOLO11n 训练到 Streamlit 全链路实战【实战源码】
后端