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
相关推荐
2501_930707781 小时前
使用C#代码在 PowerPoint 中组合或取消组合形状
开发语言·c#
晚烛1 小时前
CANN 调试工具与性能剖析:从日志分析到 NPU 行为追踪的完整调试体系
开发语言·windows·python·深度学习·缓存
惊鸿一博2 小时前
图标加载方式_zeroIcon_是否加前缀mdi
开发语言·前端·javascript
森G2 小时前
TypeScript 基础类型
开发语言·typescript
鹿导的通天塔2 小时前
99%的人都不知道Codex 的 goal 神技!完整设置及提示词模板教学
后端
huipeng9263 小时前
企业级微服务开发实战(一):项目启动与工程化设计
java·开发语言·spring boot·spring cloud·微服务·云原生·架构
爱吃土豆的马铃薯ㅤㅤㅤㅤㅤㅤㅤㅤㅤ3 小时前
java实现excel导入、下载模板方法
java·开发语言·excel
眠りたいです3 小时前
现代C++:C++14中的新语言特性和库特性
c语言·开发语言·c++
ltl4 小时前
Transformer 原论文怎么训出来的:8 张 P100、12 小时、warmup 4000 步
后端
why技术4 小时前
AI Coding开始进入第四个时代,我还没上车呢!
前端·人工智能·后端