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 小时前
Java递归方法实现面包屑导航
java·开发语言
fīɡЙtīиɡ ℡4 小时前
AI 应用系统设计
java·开发语言·人工智能
AI绘画哇哒哒4 小时前
【建议收藏!】35岁后端血泪忠告,这3类人别硬转Agent(过来人亲述)
java·人工智能·后端·ai·程序员·大模型·agent
聪明蛋子哟5 小时前
Stagehand v3多语言SDK:Python/Go/Rust/Java下的浏览器自动化统一方案
python·golang·rust
唐青枫5 小时前
一个值多种形态:Zig union、Tagged Union 与内存布局实战
后端
今天AI了吗5 小时前
Python 基础语法(一):常量、变量、输入输出与运算符
开发语言·数据库·人工智能·python·sql·深度学习·机器学习
卷无止境6 小时前
Windows 上丝滑开发 Python,并稳定构建 Docker 镜像
后端·python·docker
Nturmoils6 小时前
备份完不算完,先还原到临时库验一遍
后端
TELL5216 小时前
selenium webdriver 第二次初始化的异常
开发语言·python
Csvn6 小时前
📊 SQL 入门 Day 22:视图与物化视图
后端·sql