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
相关推荐
观远数据7 分钟前
经营闭环的最后一公里:从看见问题到解决问题之间还差什么
java·开发语言·数据库
Java面试题总结12 分钟前
Go 语言大白话入门 6 - 判断与循环
开发语言·后端·golang
m0_6174939422 分钟前
Python OpenCV 孔洞检测与缺陷分析详解与实战
开发语言·python·opencv
hsg771 小时前
简述:Rust、GeoRust、自主研发GIS平台
开发语言·后端·rust
承渊政道1 小时前
飞算Java炫技赛:Java×Unity数字孪生园区平台的从零落地记录
java·开发语言·unity·技术分享·vibe coding·飞算javaai·飞算java ai炫技赛
wdfk_prog7 小时前
嵌入式面试真题第 10 题:高优化等级下共享状态可见性、内存模型与系统级同步设计
java·linux·开发语言·面试·职场和发展·架构·c
谭光志9 小时前
Vibe Coding 时代,程序员该何去何从
前端·后端·ai编程
GoGeekBaird9 小时前
我用 BeeWeave 跑完了一次完整写作闭环
后端·github
仿生狮子11 小时前
别再说“全栈”了,AI 时代团队只认这 5 种人
前端·人工智能·后端
许彰午11 小时前
95_Python内存管理与垃圾回收
开发语言·python