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 分钟前
AI 知识库搜索不准?问题出在分块
后端
夕颜11142 分钟前
Multica 使用心得介绍
后端
代码中介商1 小时前
C++左值与右值:核心判断法则详解
开发语言·c++
星轨zb2 小时前
LangChain4j 集成 Spring Boot:会话记忆 NPE 的根源与 ChatMemoryProvider 正确配置
java·spring boot·后端·langchain4j
JAVA9652 小时前
JAVA面试-并发篇 05-并发包AQS队列实现原理是什么
java·开发语言·面试
混凝土拌意大利面2 小时前
TG-BOOT springboot 功能集散开发框架(AI 协作友好)
人工智能·spring boot·后端
Halo_tjn2 小时前
反射与设计模式1
java·开发语言·算法
珊瑚里的鱼3 小时前
手撕单例模式中的饿汉模式和懒汉模式,懒汉模式还要再多加一个C++11版本的
开发语言·c++·单例模式
_不会dp不改名_3 小时前
python-opencv环境搭建
开发语言·python·opencv
小村儿3 小时前
连载12- Cluade code 的MCP 到底还用不用
前端·后端·ai编程