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
相关推荐
KaMeidebaby3 分钟前
卡梅德生物技术快报|抗体筛选:抗体筛选中的噬菌体展示四参数调优——从流程设计到数据验证
开发语言·前端·javascript
大黄说说6 分钟前
接口频繁超时、报错?后端常见排查思路总结
开发语言·php
Ai拆代码的曹操9 分钟前
RocketMQ 消息堆积排查实战:从 20 个消费者线程卡死到 rebalance 死亡螺旋
后端·rocketmq
跨境小陈10 分钟前
2026 年如何使用 Python 抓取 Reddit 数据
开发语言·网络·python
吃饱了得干活16 分钟前
@Transactional 又失效了?把这 8 个坑全填了!
java·后端·spring
颜进强16 分钟前
从零搭建私人 RAG 知识库:让项目决策真正“可检索、可追溯”
前端·后端·ai编程
颜进强19 分钟前
Embedding 模型介绍:热门模型对比与应用场景
前端·后端·ai编程
颜进强20 分钟前
LanceDB 基础使用:用 TypeScript 完成第一次向量检索
前端·后端·ai编程
武子康22 分钟前
低延迟不是更快地猜:EOU / Barge-in / Turn Protocol 必须统一(4 种结束 + Generation Fencing + 9 类可复现场景)
人工智能·后端·llm
颜进强28 分钟前
Ollama 从入门到实践:本地模型运行、API 调用
前端·后端·ai编程