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
相关推荐
Mininglamp_271822 分钟前
Claude Code 封禁中国开发者之后:本地 AI 编程工具的替代方案实测
开发语言·人工智能·windows·开源软件·ai-native
思麟呀33 分钟前
C++17(三)if constexpr+折叠表达式
开发语言·c++
醉城夜风~34 分钟前
Java详解经典算法题:接雨水(三种实现方案+原理剖析)
java·开发语言·算法
明理的信封37 分钟前
AI 基础设施的“去 Python 化“:Rust 与 C# 的两条替代路径
人工智能·python·rust
qydz1143 分钟前
杰理开发基础知识(3)
开发语言·嵌入式开发·杰理科技
贾斯汀frank44 分钟前
C# 15 类型系统改进:Union Types
开发语言·windows·c#
阿里嘎多学长1 小时前
2026-07-10 GitHub 热点项目精选
开发语言·程序员·github·代码托管
CHHH_HHH1 小时前
【C++11】深入解析C++可变参数模板
开发语言·c++·算法·stl·c++11
IT_陈寒2 小时前
SpringBoot自动配置不是你以为的那样的智能
前端·人工智能·后端
jimy13 小时前
C语言模拟对象、方法:“函数指针+结构体“复用函数指针指向的函数体
c语言·开发语言