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
相关推荐
某鹏2 分钟前
JDK 28 值类:省一半内存,慢三成
后端
J.YA11 分钟前
Java I/O 总结
java·开发语言
tong_li12 分钟前
给 C++ 后端服务接入企业微信告警:Webhook 原理、架构设计与生产级实现
c++·后端
SEO_juper23 分钟前
Go 全站 H1 批量检查工具:并发抓取,找出 H1 数量不对的页面
开发语言·后端·golang
木易 士心24 分钟前
Web 端反爬与反抓包防御体系全解析
前端·后端·web安全
Brain 博览记24 分钟前
脑科学前沿 | 聚焦:TMS 单神经元机制、癫痫网络、感觉交叉可塑性、记忆巩固、EEG 自动化
运维·开发语言·网络·论文阅读·学习·自动化·php
长不大的杨瑞杰34 分钟前
Spring Boot 4 + Java 25 虚拟线程实战:配置、压测、限流与线上排障
java·spring boot·后端·spring·软件工程
AAA修煤气灶刘哥37 分钟前
美团把数据研发的 20 多次操作收进 5 个命令,Agent 怎么过上线这一关?
人工智能·后端·agent
只睡四小时43 分钟前
LoAF 归因:原生 JS 每次输入 201 次布局读取
开发语言·javascript·性能优化·ecmascript·甘特图·前端性能·loaf
ShineWinsu1 小时前
对于Qt:QMediaPlayer和QVideoWidget的解析
开发语言·c++·qt·视频·客户端·qmediaplayer·媒体播放器