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
相关推荐
来恩100333 分钟前
C# 类与对象详解
开发语言·c#
komo莫莫da1 小时前
寒假刷题Day19
java·开发语言
ElseWhereR1 小时前
C++ 写一个简单的加减法计算器
开发语言·c++·算法
计算机-秋大田2 小时前
基于微信小程序的电子竞技信息交流平台设计与实现(LW+源码+讲解)
spring boot·后端·微信小程序·小程序·课程设计
※DX3906※2 小时前
cpp实战项目—string类的模拟实现
开发语言·c++
wjs20242 小时前
Nginx 安装配置指南
开发语言
美味小鱼2 小时前
实践Rust:编写一个猜数字游戏
开发语言·游戏·rust
Dr.勿忘3 小时前
C#面试常考随笔8:using关键字有哪些用法?
开发语言·unity·面试·c#·游戏引擎
dal118网工任子仪3 小时前
92,[8] 攻防世界 web Web_php_wrong_nginx_config
开发语言·php
wjs20243 小时前
SQLite Update 语句详解
开发语言