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
相关推荐
十年Java程序媛7 分钟前
MySQL 时间字段踩坑!date、datetime、timestamp 怎么选
android·java·开发语言·数据库·mysql·面试·个人开发
吃我一窝jio12 分钟前
Java输出流全解析
java·开发语言·笔记
Rain的Java大神之路44 分钟前
CNN 要学到什么程度?Java 工程师转 AI 的能力边界、推理落地与避坑指南
java·后端·面试
IT枫斗者1 小时前
AI Coding 蜜月期之后,我们重新思考了 AI 提效
java·开发语言·人工智能·gateway·fastapi
weixin_307779131 小时前
Jupyter SQL 表血缘分析并导出 Excel
开发语言·python·sql·算法·excel
benchmark_cc1 小时前
如何用 Python 计算盈亏痛苦比(Gain-to-Pain Ratio)?
开发语言·python·数据分析·pandas·量化交易·股票数据·quantdash
sbjdhjd1 小时前
后端编程语言 PHP 笔记(第 1–3 章)|PHP 简介、版本与运行环境安装
开发语言·人工智能·笔记·后端·python·ai·php
FL16238631291 小时前
MATLAB R2026b下载和安装教程
开发语言·matlab
夕水1 小时前
夕水文学网502 故障 —— 爬虫把 Node 堆内存吃爆
javascript·后端·node.js
geovindu1 小时前
python:DBSCAN
开发语言·后端·python·算法