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
相关推荐
清水白石0086 小时前
Python 编程实战全景:从基础语法到插件架构、异步性能与工程最佳实践
开发语言·python·架构
吴文周6 小时前
告别重复劳动:一套插件让 AI 替你写代码、修Bug、做测试、上生产
前端·后端·ai编程
Cyeam6 小时前
Roadbook CSV:一行 CSV 秒变高德地图路书
后端·开源·aigc
懒狗小前端7 小时前
做了一个 codex 的中文文档网站,做的不好可以随便喷
前端·后端
Halo_tjn8 小时前
Java 基于字符串相关知识点
java·开发语言·算法
梦想的颜色8 小时前
java 利用redis来限制用户频繁点击
java·开发语言
报错小能手8 小时前
Swift 并发 Combine响应式框架
开发语言·ios·swift
Eric_见嘉8 小时前
在职前端 Agent 配置分享
前端·后端·agent
Ares-Wang9 小时前
Flask》》 Flask-OpenID 认证、 OpenID Connect (OIDC)
后端·python·flask
掘金码甲哥9 小时前
这篇优雅安装k8s集群的姿势,请务必投喂给AI智能体, 包装包活的那种!
后端