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
相关推荐
花月C3 分钟前
Spring IOC:容器管理与依赖注入秘籍
java·开发语言·rpc
ylfhpy9 分钟前
Java面试黄金宝典22
java·开发语言·算法·面试·职场和发展
小白学大数据13 分钟前
异步读取HTTP响应体的Rust实现
网络协议·http·rust
老友@21 分钟前
Kafka 全面解析
服务器·分布式·后端·kafka
Java中文社群23 分钟前
超实用!Prompt程序员使用指南,大模型各角色代码实战案例分享
后端·aigc
..过云雨34 分钟前
11. 【C++】模板进阶(函数模板特化、类模板全特化和偏特化、模板的分离编译)
开发语言·c++
风象南42 分钟前
Spring Boot 实现文件秒传功能
java·spring boot·后端
橘猫云计算机设计43 分钟前
基于django优秀少儿图书推荐网(源码+lw+部署文档+讲解),源码可白嫖!
java·spring boot·后端·python·小程序·django·毕业设计
黑猫Teng1 小时前
Spring Boot拦截器(Interceptor)与过滤器(Filter)深度解析:区别、实现与实战指南
java·spring boot·后端
小智疯狂敲代码1 小时前
Java架构师成长之路-框架源码系列-整体认识Spring体系结构(1)
后端