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
相关推荐
陈随易4 小时前
FFmpeg 9.0 发布,代号 Lei,音视频处理再升级
前端·后端·程序员
隐积5 小时前
3.1.7.Qt容器大家族(3):QVariant——万能盒子
开发语言·qt
k4m7v2pz6 小时前
把 Bevy 0.14 游戏移植到 R36S 掌机:一场与“无窗口系统“的搏斗
linux·rust·bevy·r36s·rk3326·开源掌机
doiito7 小时前
【Agent Harness】流马(Gliding Horse)DeepSeek Responses API 接入介绍
rust·系统设计·ai agent
凌虚7 小时前
面向 MySQL 用户的 PostgreSQL 快速上手指南
数据库·后端·架构
名字还没想好☜8 小时前
Next.js ‘use client‘ 到底加在哪:Server/Client Components 边界与常见报错
开发语言·前端·javascript·react·next.js
IT_陈寒8 小时前
Vite静态资源引用这个坑我踩得有点疼
前端·人工智能·后端
初级代码游戏9 小时前
iOS开发 Swift 速记1:变量和基本数据类型
开发语言·ios·swift
前端开发张小七9 小时前
Java 学习笔记 · 第一课:基础语法与核心概念
java·后端
海盗12349 小时前
微软技术周报 ——2026-08-03
后端·python·microsoft·c#·.netcore