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
相关推荐
怕浪猫1 小时前
FDE 如何正确解决现场项目工程性的问题
前端·后端·ai编程
GreenTea1 小时前
vLLM 与 SGLang KV Cache 底层实现机制深度调研报告
前端·后端·算法
考虑考虑1 小时前
Java实现hmacsha256加密算法
java·后端·java ee
凤山老林2 小时前
聊聊企业级 API 安全:Spring Boot 落地 OAuth 2.1、mTLS 与接口签名防篡改
spring boot·后端·安全·oauth
言乐63 小时前
Python加速器4跨境网络加速器
运维·服务器·开发语言·网络·python
林鹿3 小时前
maven属性与groovy变量对照表
后端
金金计较.3 小时前
Go语言-3
java·开发语言·golang
烽火戏诸诸诸侯3 小时前
AI 让我的独门小工具焕发第二春
后端·ai编程·vibecoding
张小凡vip4 小时前
python--爬虫--经验积累的遇到的坑
开发语言·爬虫·python
狼爷4 小时前
硅谷爆火的FDE是AI新风口,还是高级外包?
后端·全栈