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
相关推荐
jimy11 小时前
标准的动态类型定义与“多态”无关,非多态对象同样会出现动态类型不同于静态类型的情形
开发语言·c++
冬、不眠的夜1 小时前
Nuitka 将 python 程序编译成 exe 指南
开发语言·python
CVer儿2 小时前
起源1引擎相关知识点2--World Brush+func_detail
开发语言
EAIReport2 小时前
SpringBoot 与 SpringCloud 深度解析:核心特点、差异与协同关系
spring boot·后端·spring cloud
梦里寻码2 小时前
从 0 到 1 用 NestJS + LangChain 搭一套可售卖的 SaaS AI 客服:挂件一行代码接入,知识库秒变 SEO 帮助中心
前端·后端·github
Source.Liu2 小时前
【A11】客户端登录流程笔记
windows·rust
imDwAaY2 小时前
程序为什么会卡在死锁里?从四个必要条件到预防与解除
后端·操作系统
Bazingga2 小时前
知识注入的两条路:RAG知识库与Skills蒸馏
后端
薛之谦_2 小时前
JAVA 多线程编程:从基础原理到实战应用
java·开发语言
LMT_Lanmantech2 小时前
Creo许可降本增效:不增购,也能让现有许可发挥更大价值
java·大数据·开发语言