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
相关推荐
旺仔学长 哈哈几秒前
Spring Boot 智能停车场管理系统---附源码+数据库文档
数据库·spring boot·后端·智能停车场
用户83562907805115 分钟前
使用 Python 在 PDF 中绘制线条、矩形和自定义图形
后端·python
霸道流氓气质19 分钟前
Java中集成Smile 技术教程:从入门到工程实践
java·开发语言
进击的丸子44 分钟前
虹软人脸服务器SDK-C++语言Demo实操指南
后端·算法
BerrySen1781 小时前
迈向 Next-Gen Java:企业级高并发架构演进与大模型 Agent 落地深度实战
java·开发语言·架构
程序员鱼皮1 小时前
Claude Opus 5 全新发布,7 大项目实测,夯还是拉?半价吊打 Fable 5?
前端·后端·ai编程
Nebula_g1 小时前
Java实现本地Socket通信(三)
java·开发语言·学习·socket·可视化
一水1 小时前
java运行排错,新码旧jar
java·开发语言·jar
Conan在掘金2 小时前
ArkTS 进阶之道(11):build() 重渲边界——状态变为啥只刷依赖组件
后端
xiaobaoyu2 小时前
mac+idea快捷键
后端