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
相关推荐
考虑考虑2 小时前
JDK26中的List.ofLazy()
java·后端·java ee
小蒜学长2 小时前
基于SpringBoot的公寓报修管理系统的设计与实现(代码+数据库+LW)
java·spring boot·后端·公寓报修管理系统·多角色协同
Ada's3 小时前
【计算机基础系列】003:Python数据结构
开发语言·数据结构·python
云浪3 小时前
Go源码分析:搞懂 Go 是如何实现堆的
后端·go·源码阅读
2601_962885723 小时前
如何用 Python 计算 TRIX 三重指数平滑均线指标?
开发语言·python
还卿一钵无情泪4 小时前
Unsloth 微调 构建自己的大模型 没有GPU也能微调
linux·开发语言·人工智能·python·大模型·nlp·unsloth
倔强的石头1065 小时前
应用账号最小权限实践:读写账号、报表账号、运维账号分层
java·运维·开发语言
传人once5 小时前
页面中心圆圈放大效果如何写
开发语言·javascript·ecmascript
NeilYuen5 小时前
【C++】STL源码仿写(二):vector
开发语言·c++
调试人生的显微镜6 小时前
iOS开发入门:Interface Builder、基础控件及UITextField详解
后端·ios