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
相关推荐
MM_MS15 小时前
C# 线程与并发编程完全指南:从基础到高级带详细注释版(一篇读懂)
开发语言·机器学习·计算机视觉·c#·简单工厂模式·visual studio
t***316515 小时前
QT开发:事件循环与处理机制的概念和流程概括性总结
开发语言·qt
Dr丶net15 小时前
🔥NestJS 接口文档神器!nestjs-knife4j-plus 让 Swagger 颜值与功能双飞跃
后端
我家领养了个白胖胖15 小时前
arthas 我愿称为最强辅助工具
java·后端
今天也很困15 小时前
Samba 配置详解
后端
badmonster015 小时前
AI ETL需要不同的原语:从构建CocoIndex中学到的Rust经验🦀
rust·aigc
龙泉寺天下行走15 小时前
[PowerShell 入门教程] 第9.5天(间章):PowerShell 常见 Cmdlet 速查手册
开发语言·php
进击的野人15 小时前
Node.js文件系统(fs模块)深度解析与实践应用
后端·正则表达式·node.js
muxin-始终如一15 小时前
Semaphore 使用及原理详解
java·开发语言·python
前端fighter15 小时前
全栈项目:旅游攻略系统
前端·后端·源码