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
相关推荐
白帽攻防录12 小时前
SRC 挖洞:PostScript 打印机驱动双 RCE,打印服务器怎么变成内网跳板
开发语言·网络安全·php·内网安全
十年Java程序媛12 小时前
Java枚举Enum完整教程|替代静态常量,开发与面试要点
java·开发语言·spring boot·后端·面试
我是人✓12 小时前
SpringBoot静态资源映射揭秘
java·spring boot·后端
全栈弄潮儿13 小时前
Python实战第7期:字典与集合
后端·python·编程语言
2603_9651481113 小时前
电商选品调研:通过关键词搜索API获取市场热销商品,结合商品详情API分析竞品卖点与定价
开发语言·数据库·人工智能·python·信息可视化
码事漫谈13 小时前
DeepSeek 又更新!但怎么有个分数往下掉?
后端
吃饱了得干活13 小时前
用 PageHelper 同步数据到 ES:能跑,但这几个坑得先知道
后端·elasticsearch
lpfasd12313 小时前
node-sass 停止维护!老项目迁移 Dart Sass 完整教程
前端·rust·sass
金銀銅鐵13 小时前
[Java] 借助GUI展示class文件的内容(v1.0版本)
jvm·后端·ai编程