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 小时前
当公司不久后变成冒险者公会,我担心什么
后端
星落梦生3 小时前
SpringAOP基础笔记(7)
java·开发语言
Csvn4 小时前
Nginx 负载均衡进阶与健康检查:哈希、keepalive 池与 DNS 自愈
后端·nginx
皮皮林5515 小时前
京东又开源一款新框架,用起来真优雅!
后端
学长毕设5 小时前
基于SpringBoot智慧养老服务平台设计与实现-附源码
java·spring boot·后端
曹牧6 小时前
Java:“刷新雪崩”
java·开发语言
郝学胜-神的一滴6 小时前
Effective STL 条款03:容器中的对象复制要廉价且正确
开发语言·数据结构·c++·算法·rpc·stl
西西弗Sisyphus7 小时前
C++ explicit 关键字工程实践
开发语言·c++
郝学胜-神的一滴8 小时前
Effective Python 条款35:用类封装替代生成器异常注入
开发语言·人工智能·python·金融·pandas·scikit-learn·matplotlib
行百里er8 小时前
【Spring Insight 技术分享】跨服务调用链路是怎么串起来的?
后端·spring·开源