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
相关推荐
csbysj20202 分钟前
SQL UNION 操作符详解
开发语言
Volunteer Technology3 分钟前
Spring AI MCP案例
java·开发语言·数据库
郝学胜-神的一滴6 分钟前
干货版《算法导论》04:渐近复杂度与序列接口实战
java·开发语言·数据结构·c++·python·算法
zzzsde6 分钟前
【Linux】信号处理(3)信号处理&&valatile关键字
linux·运维·服务器·开发语言·算法
米丘6 分钟前
新一代代码格式化工具 Oxfmt/Oxlint
前端·rust·前端工程化
星栈6 分钟前
投影挂了怎么办?我的 CQRS 三层容错方案
数据库·后端·开源
杨运交9 分钟前
[017][web模块]基于计数器的接口幂等性与访问限流设计实战
spring boot·后端
_Evan_Yao9 分钟前
缓存与数据库的“双写悖论”:一致性的常见陷阱与破局之道
java·后端·缓存
Dylan的码园12 分钟前
2026年免费远程控制软件哪个好?ToDesk向日葵UU远程免费版横评,不限次数不限时长
服务器·开发语言·php
_Rookie._14 分钟前
部署python后端,以及Dockerfile 的 RUN CMD ENTRYPOINT字段
开发语言·python