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
相关推荐
IT_陈寒12 小时前
React的useEffect依赖数组把我坑惨了,真相其实很简单
前端·人工智能·后端
Oneslide13 小时前
ubuntu 手动安装claude
后端
GetcharZp21 小时前
玩转 Linux 机器视觉:手把手带你搞定 Ubuntu 下海康工业相机 C++ SDK
后端
星星在线1 天前
MusicFree:一个「All in One」的个人音乐服务器,让听歌回归简单
前端·后端
IT_陈寒1 天前
Redis的SETNX并发问题让我加了三天班
前端·人工智能·后端
demo007x1 天前
Docling 文档转换以及技术架构分析
前端·后端·程序员
袋鱼不重1 天前
我的神奇同事,AI 用多了居然写了个 Open In Codex
前端·后端·ai编程
用户8356290780511 天前
使用 Python 操作 Word 内容控件
后端·python
像我这样帅的人丶你还1 天前
啥? 前端也要会干Java?🛵🛵🛵
后端
Hommy881 天前
【剪映小助手】添加贴纸接口(Add Sticker)
后端·github·剪映小助手·视频剪辑自动化·剪映api