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
相关推荐
Lethehong1 分钟前
从轻点到落块:Rokid AIUI 游戏《叠叠乐》开发实践
java·开发语言·游戏
用户48678952533909 分钟前
支付清结算(三):T+1 在等什么
后端·saas
nezuko3527 分钟前
用 AI 把代码改写成 Rust 之后,怎么证明它没改坏?我做了个开源工具
rust
全速向光38 分钟前
用 Three.js 从零打造一棵会发光的 3D 圣诞树
开发语言·javascript·3d
智驭未来掌门人43 分钟前
Qt + SQLCipher 深度集成实战:从源码编译到加密驱动落地的完整复盘
后端
codeejun1 小时前
每日一Go·MySQL-28、账户转账事务设计
开发语言·mysql·golang
ShineWinsu1 小时前
对于Qt:QSS样式属性的解析
开发语言·c++·qt·面试·盒子模型·客户端·qss
reasonsummer1 小时前
【办公类-178-01】20261204医保需要“幼儿园园通学籍证明截图”(Python页面截图+转PDF)
开发语言·c#
夜雪轻寒1 小时前
AI 工具踩坑录:Prompt 我越写越长,模型反而越来越笨,删到第三版才明白它在装
java·开发语言·人工智能·语言模型·自然语言处理·prompt
吴名氏.2 小时前
全栈跃迁:Java 后端 27 讲【7】MyBatisPlus进阶与慢SQL治理
java·开发语言·数据库·sql·大模型·sql调优