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
相关推荐
取经蜗牛5 分钟前
Python 第一阶段完全指南:从零到第一个实用工具
开发语言·python
不会c+35 分钟前
02-SpringBoot配置文件
java·spring boot·后端
dog25037 分钟前
从重尾到截断流量模型的演进
开发语言·php
qq_401700411 小时前
Qt QSS 完全入门写出漂亮界面以及解决样式不生效问题
开发语言·qt
雨辰AI2 小时前
生产级实战:人大金仓 V9 标准化运维手册(日常巡检 + 监控告警 + 应急处置)
java·运维·数据库·后端
我是一颗柠檬2 小时前
【Java项目技术亮点】覆盖索引与索引下推优化
android·java·开发语言
2601_962440842 小时前
计算机毕业设计之健身房管理系统的设计与实现
java·开发语言·课程设计·旅游·宠物
TeamDev2 小时前
JxBrowser 9.3.0 版本发布啦!
java·后端·c#·混合应用·jxbrowser·浏览器控件·异步媒体设备
第六五2 小时前
Python 内置装饰器
开发语言·python
旖-旎2 小时前
QT系统篇(5)(下)
开发语言·c++·qt