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
相关推荐
songroom17 分钟前
Kimi K3:Rust封装XTP接口详细教程实践
开发语言·后端·rust
kebeiovo27 分钟前
游戏服务端开发:Actor模型详解(Go语言)
开发语言·后端·golang
红烧大青虫44 分钟前
setInterval 倒计时实现:60s 验证码发送逻辑
后端·华为·harmonyos·鸿蒙系统
迷途呀1 小时前
Python:函数中的参数类型
开发语言·笔记·python·langchain·nlp
Herbert_hwt1 小时前
建立Java程序开发
java·开发语言
小村儿1 小时前
连载14-实战篇--一个半月,我一个人和 Claude Code 搭出一套数字人工程
前端·后端·ai编程
你驴我1 小时前
WhatsApp 多账号下消息已读回执的实时聚合与推送实践
后端·python
用户208046804562 小时前
Python3 注释编写完全指南:从基础规范到高效实践
后端
愚公移码2 小时前
蓝凌EKP18产品:流程虚拟机(PVM)
java·开发语言·前端
苏三说技术2 小时前
Jackson3来了,变化真大!
后端