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
相关推荐
南囝coding1 分钟前
这款AI自动生成播客工具,必须收藏!
前端·后端
追逐时光者6 分钟前
C#/.NET/.NET Core优秀项目和框架2025年5月简报
后端·.net
come1123428 分钟前
Claude 写 PHP 项目的完整小白教程
开发语言·php
虾球xz31 分钟前
CppCon 2015 学习:Concurrency TS Editor’s Report
开发语言·c++·学习
板鸭〈小号〉37 分钟前
命名管道实现本地通信
开发语言·c++
37手游后端团队38 分钟前
8分钟带你看懂什么是MCP
人工智能·后端·面试
维维酱1 小时前
Rust - 消息传递
rust
火兮明兮1 小时前
Python训练第四十五天
开发语言·python
小华同学ai2 小时前
千万别错过!这个国产开源项目彻底改变了你的域名资产管理方式,收藏它相当于多一个安全专家!
前端·后端·github
Vowwwwwww2 小时前
GIT历史存在大文件的解决办法
前端·git·后端