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
相关推荐
W.A委员会2 小时前
JS原型链详解
开发语言·javascript·原型模式
止语Lab3 小时前
Go并发编程实战:Channel 还是 Mutex?一个场景驱动的选择框架
开发语言·后端·golang
小码哥_常3 小时前
Spring Boot一键限速:守护你的接口“高速路”
后端
她说彩礼65万3 小时前
C# 实现简单的日志打印
开发语言·javascript·c#
绿浪19843 小时前
c# 中结构体 的定义字符串字段(性能优化)
开发语言·c#
阿丰资源3 小时前
基于SpringBoot的物流信息管理系统设计与实现(附资料)
java·spring boot·后端
杨艺韬3 小时前
Rust编译器原理-第11章 闭包:匿名函数的编译器实现
rust·编译器
杨艺韬3 小时前
Rust编译器原理-第15章 MIR 优化:编译器的中间表示与优化管线
rust·编译器
房开民3 小时前
可变参数模板
java·开发语言·算法
杨艺韬3 小时前
Rust编译器原理-第6章 单态化:泛型的编译期展开
rust·编译器