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
相关推荐
ShadowYD4 小时前
Agent Loop:一个让 AI 编程 Agent 从"会写代码"进化到"闭环交付"的开源 Skill(适配国内外主流 Code Agent)
后端
考虑考虑5 小时前
nohup启动java程序
后端·自动化运维
aramae7 小时前
模拟实现strcmp()(C语言)
c语言·开发语言·后端
泡海椒8 小时前
PDF 表格样式优化:jquick-pdf 边框、圆角、背景色
java·开发语言·pdf
Beyond_System|系统之外8 小时前
【学编程】Python基础编程题100道(21-60)
开发语言·python·算法
根目录下的猫9 小时前
RK3588适配的轻量级AI模型推荐
人工智能·后端·python·目标检测
景熙55239 小时前
15.Java 8 Stream 流入门到实战
java·开发语言·数据结构
星栈10 小时前
用 Rust 写 Agent 服务 -- adk-rust 上手记
后端·agent
杨运交10 小时前
[071][验证码模块]基于Spring拦截器的验证码认证设计思想
java·后端·spring