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
相关推荐
明月_清风10 分钟前
用自然语言控制 Blender:开源项目 Blender MCP 深度介绍
人工智能·后端
weixin_3077791316 分钟前
C++代码实现MATLAB中的ode45函数功能
开发语言·c++·算法·matlab
是立不是利1 小时前
大文件导致请求被拒的连锁反应
开发语言·前端·javascript
JaguarJack1 小时前
Whim 是什么?一门把 PHP 被否决的设想真跑起来的实验语言
后端·php·服务端
野生技术架构师1 小时前
1200 道 JAVA 面试题(各大企业常见面试题及答案)
java·开发语言
明月_清风1 小时前
MHS:AI Agent 开始连接物理世界
人工智能·后端·网络协议
“AI国潮设计-小江”1 小时前
【Python/SDXL实战】潮汕国潮IP视觉落地:普宁美食猫IP & 创意甜品设计(附ComfyUI工作流思路)
开发语言·人工智能·python·prompt·aigc
ssshooter1 小时前
Node.js 天生就是异步的,为什么还要消息队列?
javascript·后端·面试
福兮说2 小时前
Gin 项目里的错误处理:让 Controller 不必知道错误是怎么来的
后端·go·gin·架构设计
Yyyyyy~2 小时前
【java】类和对象
java·开发语言