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
相关推荐
麦麦麦当劳大王6 小时前
【油猴脚本】Boss直聘 岗位职责复制
开发语言·前端·javascript
深蓝AI6 小时前
JWT 不是登录方案:三种登录态架构怎么选
后端
starzy19907 小时前
深入理解Scala Map:从实现原理到工程实践
开发语言·后端·scala
只睡四小时7 小时前
Three.js Sub-tick:漏判 60.7%→0
开发语言·javascript·性能优化·ecmascript·游戏开发·three.js·碰撞检测
卷无止境7 小时前
凌晨三点的绿灯
后端
码农小河668 小时前
基于SSM+JSP的高校专业信息管理系统【附源码+数据库】
java·开发语言·数据库
excel8 小时前
基于 GPT 的自动发布文章接口方案:从一句话或一张图片生成并发布内容
前端·javascript·后端
东鹏特饮10 小时前
系统运维(传统/通用运维)面试题
开发语言·php
风若飞10 小时前
Spring Ai 入门遇到问题1
java·后端·spring
今天要早睡_10 小时前
C++01_入门基础复习
开发语言·c++