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
相关推荐
__zRainy__20 分钟前
Node系列 · ORM:Sequelize 简介
数据库·后端·node.js
梦想的旅途231 分钟前
Python实现企业微信文本消息发送
开发语言·python·企业微信
大鹏说大话1 小时前
美业微信会员系统哪个好
开发语言
AskHarries1 小时前
OpenClaw 如何查看历史对话和响应时间?
后端
n8n1 小时前
Spring Boot 3.2+ 新特性、Spring AI 核心架构与 API Key 安全管理技术文档
后端
fireworks991 小时前
接口鉴权(401与403)
java·后端
n8n1 小时前
Java 21 虚拟线程(Virtual Threads)
后端
Csvn2 小时前
🐍 Day 5: Python 函数详解 — 参数、作用域与一等公民
人工智能·后端
wno7042 小时前
Spring Boot中使用Servlet
spring boot·后端·servlet
老郑聊AI业财智造2 小时前
Spring AI 技术架构与源码分析
java·人工智能·后端·spring·架构·软件工程