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
相关推荐
oliver_sys_log8 分钟前
绕过 Yearning 查询体验限制:我做了一个 DataGrip 只读 SQL 代理
后端·mysql
水深火乐10 分钟前
golang-jwt v5 入门
后端
carson95512 分钟前
基于springboot和vue的文本文件上传下载在线编辑功能
后端
n8n18 分钟前
Spring AI 提示词工程进阶:System / User / Assistant 角色、Prompt Template 动态拼装与多角色人设切换
后端
步行cgn29 分钟前
Spring Boot 主入口类上的 @Enable 和 @Scan 注解详解
java·spring boot·后端
梦醒沉醉33 分钟前
4、Rust参考手册——Crate和源文件
rust
chainbees36 分钟前
Windows 系统 Rust 运行环境搭建
rust
en.en..37 分钟前
C语言核心解析:#define与typedef本质区别
开发语言·c++·算法
2601_9669496543 分钟前
批量获取多只股票五档盘口的极简方案:QuantDash Python SDK 实战指南
开发语言·python·数据分析·pandas·量化交易·股票数据·quantdash
Lyra_Infra1 小时前
云效主机部署场景下 Python 服务生命周期问题复盘
后端·python