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
相关推荐
三8443 分钟前
redis三大机制:配置、持久化、主从复制(getshell 原理地基)
开发语言·php
万年咸鱼8 分钟前
Java PrintStream 详解:从基础用法到实战技巧
java·开发语言·python
程序员清风17 分钟前
聊聊怎么缓解找工作的焦虑感?
java·后端·面试
guwentian24 分钟前
手撕 MCP:用 TypeScript 从零写一个能跑的最小客户端(附可运行 demo)
开发语言·nodejs·mcp
不一样的少年_34 分钟前
明明做了很多事,为什么简历看起来还是没含金量?
前端·后端·招聘
newerp40 分钟前
Golang 函数调用的瞬间:栈帧、拷贝栈与逃逸分析
后端·程序员·go
会编程的吕洞宾40 分钟前
LangChain4j RAG 分块策略实战:检索质量提升 80% 的 Chunking 调优全解
java·人工智能·后端
newerp40 分钟前
Golang 网络轮询器 netpoll:把阻塞 IO 变成事件通知
后端·程序员·go
万物智能43 分钟前
HDMI 输出—【万物智能之开源鸿蒙OpenHarmony系统实战开发系列教程】
后端·架构
秋田君1 小时前
Qt_串口编程
开发语言·qt