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
相关推荐
zh_xuan4 分钟前
c++ jthread
开发语言·c++·jthread
旧梦95275 分钟前
Java 捕获多个异常:从基础语法到最佳实践
java·开发语言
步行cgn9 分钟前
Spring Boot 启动报错:MissingServletWebServerFactoryBean 的排查与解决
java·spring boot·后端
海兰40 分钟前
【 Python 量化交易】开篇
开发语言·python·信息可视化·量化交易
步行cgn44 分钟前
Spring Boot 项目打包部署详解
java·spring boot·后端
我的xiaodoujiao1 小时前
Django 基础知识详细图文教程 4-Django 视图定义与使用
开发语言·数据库·后端·测试工具·django·sqlite
l1t1 小时前
DeepSeek总结的DuckDB在 CI 中为 release 和 glibc CLI 构建启用 LTO - #24225
开发语言·数据库·ci/cd·duckdb
whitelbwwww1 小时前
c++运行RKNN
开发语言·c++
2601_962070231 小时前
差异基因富集分析(R语言——GO&KEGG&GSEA)
开发语言·golang·r语言
布莱克6051 小时前
栈(Stack)详解:定义、作用、应用场景及与队列的区别(附 C/C++ 代码)
c语言·开发语言·c++·