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
相关推荐
帅气的你2 分钟前
高并发下的防并发实战:C端/B端项目并发控制完全指南
后端
Ahtacca3 分钟前
解决服务间通信难题:Spring Boot 中 HttpClient 的标准使用姿势
java·spring boot·后端
嘻哈baby3 分钟前
局域网服务发现技术:mDNS与DNS-SD实战
后端
初次攀爬者4 分钟前
RAG知识库核心优化|基于语义的智能文本切片方案(对比字符串长度分割)
人工智能·后端
JOEH604 分钟前
🔥 Redis 缓存穿透、击穿、雪崩:别再只背八股文了,实战代码教你彻底解决!
后端·架构
亚历山大海8 分钟前
PHP HTML 实体(HTML Entities)没有被正确解码导致< 和 δ 等字符被转换
开发语言·html·php
掘金一周8 分钟前
高德地图与Three.js结合实现3D大屏可视化 | 掘金一周 1.8
前端·人工智能·后端
ServBay9 分钟前
8 个 Python 自动化脚本让你告别重复劳动
后端·python
CSDN_RTKLIB9 分钟前
C++取余符号%
开发语言·c++