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
相关推荐
xieliyu.1 小时前
Java算法精讲:双指针(二)
java·开发语言·算法
jeffer_liu2 小时前
Spring AI 生产级实战:裁判员
java·人工智能·后端·spring·大模型
何以解忧,唯有..2 小时前
Python包管理工具pip:从入门到精通
开发语言·python·pip
雪的季节2 小时前
RabbitMQ详解
开发语言
金銀銅鐵2 小时前
用 Tkinter 实现简单的猜数字游戏
后端·python
copyer_xyf2 小时前
Python 模块与包的导入导出
前端·后端·python
ice8130331813 小时前
【Python】Matplotlib折线图绘制
开发语言·python·matplotlib
夜微凉43 小时前
三、Spring
java·后端·spring
三品吉他手会点灯3 小时前
C语言学习笔记 - 44.运算符和表达式 - 运算符2 - 除法与取余运算符
c语言·开发语言·笔记·算法
copyer_xyf3 小时前
Python venv 虚拟环境
前端·后端·python