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
相关推荐
fie888913 小时前
matlab打靶法求解两点边值优化问题
开发语言·算法·matlab
skywalk816313 小时前
请结合以下说明,先完成类似python的内置函数。 然后再去完成内置库(标准款) ‌内置函数‌
开发语言·python
我不是懒洋洋13 小时前
手写一个异步日志库:从printf到高性能无锁日志
java·c语言·开发语言·c++·visual studio
郝学胜-神的一滴13 小时前
Python 高级编程 018:深挖 super
开发语言·python·程序人生·软件构建
hoiii18713 小时前
基于MATLAB实现Lamb波频散曲线求解
开发语言·matlab
李少兄13 小时前
Java 工程化基石:标准目录结构与 META-INF 元信息机制
java·开发语言
就叫_这个吧13 小时前
理解Java反射机制和内省机制应用与实践
java·开发语言·反射
道友可好14 小时前
Superpowers:给 AI 编程助手装上超能力
前端·人工智能·后端
凯尔萨厮14 小时前
创建Hibernate Web项目(配置类)
后端·hibernate
尤老师FPGA14 小时前
QT代码自适应窗口
开发语言·qt