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
相关推荐
matlab代码20 分钟前
基于matlab自助水果超市水果识别收费系统(GUI界面)【源码67期】
开发语言·matlab
hui-梦苑35 分钟前
[PHP]轻量主题函数WordPress 集成 KaTeX 数学公式渲染
开发语言·php·wordpress·katex
大圣编蚕1 小时前
Java StringWriter 详解:从入门到实战
java·开发语言·python
IT_陈寒1 小时前
Vue的computed属性竟然坑了我一把
前端·人工智能·后端
码行山野赴时序归途1 小时前
C语言预处理指令:编译前的“幕后导演“
c语言·开发语言
golang学习记1 小时前
Go 1.27新特性: json/v2使用有趣指南
开发语言·golang·json
老苗项目实战2 小时前
Java工程师高频面试题(基于近一年的真实面试记录整理)
java·开发语言·面试·预见猿份·老苗项目实战
薛定谔的悦2 小时前
一套储能 BMS 的充电电流限值,是怎么一步步算出来的
后端
小小、码农2 小时前
C++11右值引用与移动语义 —— 从拷贝资源到转移资源
开发语言·网络·c++·网络协议
逐米时代2 小时前
AR加知识库提升一次修复率
后端·restful