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
相关推荐
ziwu7 小时前
【动物识别系统】Python+TensorFlow+Django+人工智能+深度学习+卷积神经网络算法
后端·深度学习·图像识别
程序猫.7 小时前
Java零基础入门:集合进阶(下)
java·开发语言
该用户已不存在7 小时前
免费 SSL 证书缩短至 90 天,你的运维成本还能hold住吗
前端·后端·https
00后程序员7 小时前
怎么在 iOS 上架 App,从构建端到审核端的全流程协作解析
后端
Z***G4797 小时前
SpringBoot线程池的使用
java·spring boot·后端
L***d6707 小时前
Spring Boot 整合 Keycloak
java·spring boot·后端
菜鸟-017 小时前
QT:BMS_TTL
开发语言·qt
n***27197 小时前
工作中常用springboot启动后执行的方法
java·spring boot·后端
sali-tec7 小时前
C# 基于halcon的视觉工作流-章65 点云匹配-基于形状
开发语言·人工智能·算法·计算机视觉·c#
不会c嘎嘎7 小时前
【C++】深入理解多态:从用法到原理
开发语言·c++