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
相关推荐
艾莉丝努力练剑3 分钟前
【AI大模型接入SDK】Gemini模型接入知识体系
java·开发语言·网络·人工智能·网络协议·学习·http
传奇开心果编程7 分钟前
【Rust入门知识点学与练】第13课:枚举 Enum
开发语言·学习·rust
IT毕设实战小研8 分钟前
基于大数据的WTA职业网球赛事演变与竞技格局数据可视化分析
大数据·后端·爬虫·python·信息可视化·课程设计
zhanghaha131412 分钟前
Python进阶教程:28_queue 队列模块 零基础超详细教程
java·开发语言·python
司小豆17 分钟前
第七课:DeepSeek Harness 服务与依赖注入
java·服务器·开发语言·github·ai编程
weixin1997010801629 分钟前
[特殊字符]《闲鱼 + 淘宝 + 1688 三平台库存同源:二手ERP主数据治理与超卖防御》(附Python源码)
开发语言·python
IT_陈寒34 分钟前
Java字符串判等踩坑记:==和equals真的不能乱用
前端·人工智能·后端
ltqshs34 分钟前
C语言-链表例程
c语言·开发语言·链表
小灰灰搞电子36 分钟前
Rust+Slint 实现点击水波纹扩散效果按钮源码分享
rust·slint·水波纹按钮
shmily麻瓜小菜鸡39 分钟前
JavaScript / TypeScript 易踩坑知识点 —— 作用域与变量类
开发语言·javascript·typescript