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
相关推荐
半亩码田1 分钟前
C#转Python第5.1篇:异步编程:asyncio vs async/await,语法相似但机制不同
开发语言·python·c#
西瓜很甜哟13 分钟前
golang实现大文件分片上传
后端·golang·html
梦醒沉醉17 分钟前
7、Rust参考手册——属性
rust
LMT_Lanmantech26 分钟前
MATLAB合规管理:如何避免侵权赔偿和审计风险
开发语言·matlab·信息可视化
言乐635 分钟前
PythonLOLM自动生成复盘报告模型
开发语言·前端·数据库·人工智能·python
霸道流氓气质35 分钟前
HashiCorp Vault 与云 KMS 入门实战:动态密钥、SecretLeaseContainer 与 Java 集成完整指南
java·开发语言
论文复现现场43 分钟前
DeepSeek V4.1 Flash 各平台价格怎么比?缓存、峰谷计费与 Python 成本计算
开发语言·python·缓存·大模型·成本优化·deepseek
xuxigifxfh43 分钟前
牛客:HJ21 简单密码
java·开发语言·算法
sp42a1 小时前
简单的 Spring 文件上传与下载组件
java·后端·spring
步行cgn1 小时前
为什么 Spring 建议使用构造器注入?
java·后端·spring