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
相关推荐
传奇开心果编程11 分钟前
【Rust入门练中学】第5课:引用与借用
开发语言·rust·引用·编程语言理论·通用编程语言·借用
码事漫谈13 分钟前
AI 读你的提示词,其实很没耐心
后端
qetfw18 分钟前
Bash 变量:export、位置参数与默认值展开验证
linux·开发语言·chrome·bash
电子云与长程纠缠27 分钟前
UE5魂系游戏开发教程05
开发语言·学习·游戏·ui·ue5
cspttty1 小时前
2027风险管理岗准备路线:数学与应用数学如何补齐金融、SQL与Python
开发语言·python·金融
用户8356290780511 小时前
如何使用 Python 格式化 Excel 单元格中的长文本
后端·python
我命由我123451 小时前
Python 开发 - Python 的 pathlib
java·开发语言·后端·python·学习·java-ee·学习方法
IT_陈寒1 小时前
Java性能优化完全指南
前端·人工智能·后端
电子IT笔记1 小时前
对接群晖NAS,上传和删除踩坑记录
前端·后端
Mk598781 小时前
P4:把 Agent 的记忆搬进 Redis —— AgentScope-Java 工程化实战
后端