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
相关推荐
H H.2 分钟前
Java笔记:String字符串
java·开发语言·经验分享·笔记·其他
Rain的Java大神之路12 分钟前
Spring AI 还是 LangChain4j?2026 年 Java 接入大模型,我把这笔「架构赌注」的账算清楚了
java·后端·ai编程
鲸渔21 分钟前
【AI Agent系列课程26-Python 基础26】复盘:Python 接口开发知识清单
开发语言·python·ai编程
Csvn35 分钟前
Nginx 高可用网关:VIP 切换、proxy_protocol 与 SNI 分流实战
后端·nginx
Gopher_HBo38 分钟前
跟着一次导出,走完 runtime/pprof:从一张工单到一份文件
后端
sharemylove1 小时前
Java 异常处理 学习笔记
java·开发语言·经验分享·笔记·学习
西西弗Sisyphus1 小时前
Qt QML 程序是怎么跑起来的(1)qml-only
开发语言·c++·qt
用户69371750013841 小时前
大模型蒸馏到底在蒸什么?一篇文章搞懂知识蒸馏概念
前端·后端·github
CRZZX1 小时前
三引擎 Agent 方案设计与性能测试总结
后端·架构
bai2731 小时前
同一条 q=a+b:URLSearchParams 读成空格、decodeURIComponent 读成加号,11 条查询串打进裸 socket 的实测
javascript·后端