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
相关推荐
RainCityLucky5 小时前
Java Swing 自定义组件库分享(十三)
java·笔记·后端
无限的鲜花13 小时前
反射(原创推荐)
java·开发语言
yongche_shi14 小时前
ragas官方文档中文版(五十)
开发语言·python·ai·ragas·如何评估和改进 rag 应用
一路向北he14 小时前
字节钢铁军团--“提供情境,而非控制”
java·开发语言·前端
码事漫谈14 小时前
别写Prompt了,现在流行给AI“写循环”
后端
Kyrie_Li15 小时前
Spring Boot Kafka 生产级配置全解析:从入门到精通
spring boot·后端·kafka
AI行业学习15 小时前
Notepad++ 官方下载 + 完整安装 + 全套优化配置(2026最新)
开发语言·人工智能·python·前端框架·html·notepad++
Coder_Shenshen15 小时前
西门子S7CommPlus协议鉴权算法原理与流程详解
网络·后端·算法
大圣编程16 小时前
Python中continue语句的用法是什么?
开发语言·前端·python
yuhaiqiang16 小时前
随手 vibecoding 的浏览器插件已经 6000 多次下载,聊聊他的产品设计
前端·后端·面试