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 分钟前
苍穹外卖-Day10(Spring task)
java·后端·spring
我是一颗柠檬6 分钟前
【Redis】事务与Lua脚本Day7(2026年)
数据库·redis·后端·lua·database
雨落在了我的手上10 分钟前
初始java(十七):常⽤⼯具类介绍
java·开发语言
凤凰院凶涛QAQ21 分钟前
《Java版数据结构 & 集合类剖析》集合框架的封装设计与顺序表:“从 Iterable 到 ArrayList:集合框架的‘职业树“
java·开发语言·数据结构
孟华苏35 分钟前
怎么快速排查内存泄漏问题
java·开发语言·python
zz345729811336 分钟前
C语言中字符串常量存储位置
c语言·开发语言·算法·青少年编程
noipp37 分钟前
推荐题目:洛谷 P16510 [GKS 2015 #C] gRanks
java·c语言·开发语言·c++·python·算法
flyinmind38 分钟前
Java环境与Android环境中使用QuickJS
java·开发语言·javascript·quickjs
郑洁文38 分钟前
基于Python的HTTP服务漏洞信息收集工具设计与实现
开发语言·python·http
不吃鱼的羊39 分钟前
DaVinci Developer自动连接
java·开发语言