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
相关推荐
Csvn42 分钟前
Nginx 静态站点与 location 匹配:优先级、alias、缓存头与 gzip
后端·nginx
pps-key1 小时前
网络攻防入门:从“黑客梦”到合法实操(生存篇)
开发语言·web安全·php
小满zs1 小时前
Go语言第二十章(初探Gin)
后端·go
学长毕设1 小时前
基于SpringBoot军事纪念馆管理系统设计与实现-附源码
java·spring boot·后端
小满zs1 小时前
Go语言第十九章(http标准库)
后端·go
汤姆宝库2 小时前
BPE分词器的完整实现:字节对合并与词表构建
开发语言·人工智能·c#
wflynn2 小时前
GitHub 今日推荐|kiri:clone3 系统调用直达容器,2.5 毫秒启动无 runc 中间层
docker·rust·kubernetes·开源·github·containers
驭渊的小故事3 小时前
订单服务如何调用商品服务?一次 RestTemplate 跨服务调用入门
java·开发语言·php
考虑考虑3 小时前
nginx拦截url
运维·后端·nginx
GISer_Jing4 小时前
GitHub热点I
后端·ai·langchain