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
相关推荐
Rain的Java大神之路1 小时前
Spring AI 2.0 GA 深度复盘:Java 后端做 AI 的分水岭,到底画在哪?
java·后端·aigc
青石路2 小时前
不依赖 Spring,你会如何自实现 RabbitMQ 消息的消费(二)
后端·rabbitmq
Risehuxyc2 小时前
PHP中如何将字符串转成字节数组,再异或成一个字节
开发语言·php
饮水桶_T2 小时前
C++ STL00 | 六大核心组件协作框架 笔记
开发语言·算法·百度·facebook·新浪微博
Csvn2 小时前
Nginx 可观测性与工程化:指标、告警与发布回滚演练
后端·nginx
光泽雨2 小时前
IActionResult 是 ASP.NET Core Web API 中非常常用的一种控制器方法返回类型
后端·asp.net
悠仁さん3 小时前
【C++】unordered_map_set 模拟实现
开发语言·c++
唐老板3 小时前
前端和后端,转 AI 全栈怎么转
前端·后端
掘金安东尼4 小时前
中国移动 OAS 是什么:智能体开放服务空间、四项能力与「自研」说法的核实
人工智能·后端
JuiceFS4 小时前
缓存命中率 99.96%,小文件数量减少 99.92%:启智机器人 JuiceFS 生产实践
人工智能·后端·机器人