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
相关推荐
金銀銅鐵7 小时前
为什么枚举类中可以定义抽象方法
java·后端·ai编程
陈随易7 小时前
Vue 编译器换掉 source map,快了三四成
前端·后端·程序员
xiaoye-duck8 小时前
《C++ 项目:手写大模型接入 SDK》Gemini接口设计(上):初始化、全量响应实现和测试
开发语言·网络·c++·语言模型
txxzjmzlh8 小时前
SpringBoot 统⼀功能处理
java·spring boot·后端
nice_lcj52010 小时前
Java Lambda 表达式入门:怎么写、怎么用、常用方法有哪些
java·开发语言·后端·面试
码农小河6611 小时前
基于SSM+JSP+MySQL的在线医疗服务系统的设计与实现
java·开发语言·mysql
IT_陈寒11 小时前
Redis大key删除为什么会导致服务卡顿?我的线上事故复盘
前端·人工智能·后端
系统集成-鹰翔11 小时前
ERP图片改名后仍命中识别缓存:缓存键、十分钟到期与调用计数
javascript·经验分享·后端
用户83562907805111 小时前
使用 Python 在 Excel 中添加和自定义迷你图
后端·python
码事漫谈11 小时前
给AI看一颗❤️,它就开始写递归了
后端