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
相关推荐
誰能久伴不乏3 分钟前
Qt 动态属性(Dynamic Property)详解
开发语言·qt
程序猿阿越6 分钟前
Kafka源码(三)发送消息-客户端
java·后端·源码阅读
javadaydayup8 分钟前
Apollo 凭什么能 “干掉” 本地配置?
spring boot·后端·spring
似水流年流不尽思念9 分钟前
Spring MVC 中的 DTO 对象的字段被 transient 修饰,可以被序列化吗?
后端·面试
武子康10 分钟前
大数据-70 Kafka 日志清理:删除、压缩及混合模式最佳实践
大数据·后端·kafka
故此26612 分钟前
synchronized原理
后端
似水流年流不尽思念13 分钟前
为啥 HashMap 中的 table 也被 transient 修饰?其目的是什么?
后端·面试
AAA修煤气灶刘哥13 分钟前
搞定 Redis 不难:从安装到实战的保姆级教程
java·redis·后端
MrSYJ16 分钟前
全局和局部AuthenticationManager
java·后端·程序员