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
相关推荐
t***5441 天前
Clang 编译器在 Orwell Dev-C++ 中的局限性
开发语言·c++
2601_949817721 天前
Spring Boot3.3.X整合Mybatis-Plus
spring boot·后端·mybatis
oy_mail1 天前
QoS质量配置
开发语言·智能路由器·php
oyzz1201 天前
PHP操作redis
开发语言·redis·php
uNke DEPH1 天前
Spring Boot的项目结构
java·spring boot·后端
nashane1 天前
HarmonyOS 6学习:网络能力变化监听与智能提示——告别流量偷跑,打造贴心网络感知应用
开发语言·php·harmony app
zhenxin01221 天前
Spring Boot 3.x 系列【3】Spring Initializr快速创建Spring Boot项目
spring boot·后端·spring
凌波粒1 天前
Java 8 “新”特性详解:Lambda、函数式接口、Stream、Optional 与方法引用
java·开发语言·idea
前端一小卒1 天前
前端工程师的全栈焦虑,我用 60 天治好了
前端·javascript·后端
不停喝水1 天前
【AI+Cursor】 告别切图仔,拥抱Vibe Coding: AI + Cursor 开启多模态全栈新纪元 (1)
前端·人工智能·后端·ai·ai编程·cursor