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
相关推荐
烂蜻蜓2 小时前
Flask入门教程(三十一):实用函数与类API——全局工具函数速查
后端·python·flask
计算机毕设定制辅导-无忧学长2 小时前
《基于Spring Boot传承之光非遗陶瓷烧造产品交易平台的设计与实现》
java·vue.js·spring boot·后端·毕业设计
Zane19942 小时前
内存都要回收,为什么JVM偏要把堆分成新生代和老年代
java·后端
Zane19942 小时前
257 is 257 为什么是 True?小整数缓存背后还藏着一个更容易被忽略的机制
后端·python
matlab代码2 小时前
基于matlab PCA人脸识别系统【源码63期】
开发语言·matlab
Terra.K2 小时前
后端开发阶段性总结
java·开发语言·后端
学逆向的2 小时前
PE——合并节
开发语言·网络安全·pe
是个西兰花2 小时前
C++11:线程库与线程安全问题
开发语言·c++
点心的游戏开发世界2 小时前
GDScript 入门笔记(十三):字符串操作
开发语言·笔记·游戏引擎·godot
计算机学姐3 小时前
基于SpringBoot的旅游系统的设计与实现
java·vue.js·spring boot·后端·spring·java-ee·旅游