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
相关推荐
ytttr873几秒前
Qt 数字键盘实现
开发语言·qt
wearegogog1233 分钟前
C# .NET 文件比较工具 WinForms
开发语言·c#·.net
再写一行代码就下班7 分钟前
Cursor配置Java环境、创建Spring Boot项目的步骤
java·开发语言·spring boot
零陵上将军_xdr10 分钟前
后端转全栈学习-Day5-JavaScript 基础-3
开发语言·javascript·学习
摇滚侠11 分钟前
Java 零基础全套教程,类的加载过程与类加载器的理解,笔记 189
java·后端·intellij-idea
ServBay18 分钟前
为什么我劝你不要在Mac上用Docker 进行本地 AI 开发
后端
oqX0Cazj219 分钟前
2026超火Go-Zero实战:从架构原理到高并发接口落地,彻底解决接口超时、雪崩问题
开发语言·架构·golang
蝎子莱莱爱打怪21 分钟前
XZLL-IM干货系列 02|Protobuf 协议设计:从 JSON 切到二进制,每条消息省了 60%
后端·面试·架构
学会去珍惜24 分钟前
C语言简介
c语言·开发语言
思麟呀26 分钟前
C++11 核心特性(三):强类型枚举、static_assert 与 std::tuple
开发语言·c++