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
相关推荐
Lee川1 天前
mini-cursor 揭秘:从 Tool 定义到 Agent 循环的完整实现
前端·人工智能·后端
kkeeper~1 天前
0基础C语言积跬步之深入理解指针(5下)
c语言·开发语言
一直不明飞行1 天前
Java的equals(),hashCode()应该在什么时候重写
java·开发语言·jvm
盲敲代码的阿豪1 天前
Python 入门基础教程(爬虫前置版)
开发语言·爬虫·python
basketball6161 天前
C++ 构造函数完全指南:从入门到进阶
java·开发语言·c++
互联科技报1 天前
2026超融合选型:Top5品牌与市场格局解读
开发语言·perl
weixin199701080161 天前
[特殊字符] 智能数据采集:数字化转型的“数据石油勘探队”(附Python实战源码)
开发语言·python
星浩AI1 天前
OpenHuman 对比 OpenClaw、Hermes Agent
人工智能·后端·agent
想唱rap1 天前
IO多路转接之poll
服务器·开发语言·数据库·c++
小江的记录本1 天前
【Java基础】泛型:泛型擦除、通配符、上下界限定(附《思维导图》+《面试高频考点清单》)
java·数据结构·后端·mysql·spring·面试·职场和发展