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
相关推荐
bcbnb4 分钟前
Flutter-Notebook代码混淆:Android与iOS平台安全配置
后端·ios
梦醒沉醉5 分钟前
std1.97.1——default模块和clone模块总览
rust
磐链科技12 分钟前
区块链开发入门实战:用 Hardhat 与 Ethers.js 搭建你的第一个 DApp
开发语言·javascript·区块链
泡海椒15 分钟前
SpringBoot 集成 JQuick-Curl:Spring 环境完整接入教程,第三方接口调用别再到处手写模板类
后端
落木萧萧82515 分钟前
MyBatis 关联查询的四种写法,为什么最后都变回了手写 XML
java·数据库·后端
csdn2015_15 分钟前
java springboot项目,接收到的参数多个逗号
java·开发语言·spring boot
cui_hao_nan17 分钟前
Spring AOP 自调用、代理与 private 方法引发的诡异 NPE
java·后端·spring·ai开发
可乐鸡翅yeah_26 分钟前
hls.js 多实例并发踩坑,多视频页面播放器内存与冲突问题解决
开发语言·前端·javascript·音视频·hls·m3u8·m3u8在线播放
俊昭喜喜里28 分钟前
c#中的构造函数
开发语言·数据库·c#
hahaha601639 分钟前
HLS高层次综合设计--axi之burst纠偏
开发语言·算法·fpga开发·c#