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
相关推荐
用户7713970207068 分钟前
深入解析 C# Path.ChangeExtension:原来改扩展名可以这么简单
后端
zimoyin13 分钟前
深入理解 Kotlin 协程:从零实现一个 IO 优先 + 虚拟线程溢出的混合调度器
后端
雨落倾城夏未凉14 分钟前
第四章c#方法-参数数组和可选参数(16)
后端·c#
陈随易2 小时前
VSCode古法神器fnMap v9开发故事
前端·后端·程序员
用户298698530142 小时前
Java 实现 Word 文档文本查找与高亮标注
java·后端
雪隐3 小时前
个人电脑玩AI-06让5060 Ti给你打工——Qwen3.6-35B-A3B + LM Studio + openWebUI
人工智能·后端
卷无止境3 小时前
现代 C++特性大盘点:一门脱胎换骨的老语言
c++·后端
Ausra无忧3 小时前
记录在公司把单服务器升级成多服务器架构流程
前端·后端·架构
XiaoYuanCode3 小时前
Spring Cloud Alibaba实战01|Nacos入门服务注册与配置中心
后端