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
相关推荐
梦醒沉醉6 分钟前
std1.97.1——result模块细览
rust
zx_741484817 分钟前
【Python入门】爬虫实战:Requests + XPath 从基础到实战
开发语言·爬虫·python
2601_9620652517 分钟前
从零创建一个 Django 项目
后端·python·django
吴声子夜歌21 分钟前
Java——开发中通用的方法和准则(二)
java·开发语言·php
江屿风32 分钟前
C++OJ题经验总结(竞赛)5
开发语言·c++
溪语流沙35 分钟前
【Python项目实战】虚拟环境与依赖管理:venv / pip / requirements.txt实操
开发语言·python·pip
神威难绷泪35 分钟前
Linux应用软件编程:线程分离属性 互斥机制 同步机制 死锁
linux·开发语言·算法·线程
Elastic 中国社区官方博客1 小时前
从建议到修复的 4 个阶段:使用 Elastic Workflows 实现人在回路中的自动化
运维·数据库·人工智能·后端·elasticsearch·ai·自动化
研☆香1 小时前
数组方法 splice讲解 拓展
开发语言·前端·javascript
码视野1 小时前
基于 Spring Boot + Vue3 的【城市地下燃气管网微泄漏感知与相邻地下空间燃爆预警中台】设计与实现(含PRD/三端高保真源码/大屏)
java·前端·人工智能·spring boot·后端