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
相关推荐
Data_Journal7 小时前
用于网页抓取的 Node-unblocker
大数据·开发语言·数据库·python·scrapy
豆角焖肉7 小时前
SSM 聚合项目搭建:多 Maven 模块项目
开发语言·python·pycharm
Frank_refuel7 小时前
【C++八股】面向对象
开发语言·c++
m0_380743878 小时前
为 OpenAI 兼容接口配置教程
开发语言·python·node.js
凤山老林9 小时前
Spring Boot 3.x AOT 编译实战:从原理、踩坑到生产落地
java·spring boot·后端
博傅9 小时前
Spring 核心原理
java·后端·spring
万邦科技Lafite9 小时前
阿里巴巴拍立淘按图搜索商品API返回值实践:提升用户购物满意度的关键措施
开发语言·api·开放api·电商开放平台·京东开放平台
用户938515635079 小时前
掘金风格后端数据库设计实战:从用户表到分布式架构,一文搞定
后端·sql
拾光师10 小时前
Hadoop 三种运行模式:从单机调试到生产集群,一路搭过来
后端
小小龙学IT10 小时前
Qt 6 跨平台开发完全指南:从信号槽机制到实际项目落地
开发语言·qt