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
相关推荐
我是大龄程序员15 分钟前
如何使用mkcert解决本地开发环境 HTTPS 配置
后端
zhanghaha131416 分钟前
C# 系列教程_15 类 Class 保姆级系统教程(面向新手,大量示例 + 底层机理)
java·开发语言·c#
CoderYanger36 分钟前
Java EE 进阶:11. SpringBoot 统一功能处理(第三弹):统一数据返回格式+统一异常处理
java·数据库·spring boot·后端·spring·java-ee·mybatis
JaguarJack1 小时前
php-wasm-builder 1.0 发布,让 PHP 应用在浏览器里运行
后端·php·服务端
BingoGo1 小时前
php-wasm-builder 1.0 发布,让 PHP 应用在浏览器里运行
后端·php
软件技术NINI1 小时前
基于SpringBoot的滑雪场设备租赁系统
java·spring boot·后端
考虑考虑10 小时前
JDK27结构化并发
java·后端·java ee
沐言人生10 小时前
自媒体人的效率神器!监控、采集、下载、发布,这个免费开源工具全拿下!
前端·vue.js·后端
金銀銅鐵11 小时前
带您看懂字节码指令(五):控制流里有什么
java·jvm·后端
我叫黑大帅12 小时前
拒绝加字段堆屎山!利用位掩码与流程编排优雅落地 上图下文 复合状态
后端·算法·面试