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
相关推荐
励志的小陈4 小时前
贪吃蛇(C语言实现,API)
c语言·开发语言
Makoto_Kimur5 小时前
java开发面试-AI Coding速成
java·开发语言
laowangpython5 小时前
Gurobi求解器Matlab安装配置教程
开发语言·其他·matlab
wengqidaifeng5 小时前
python启航:1.基础语法知识
开发语言·python
观北海5 小时前
Windows 平台 Python 极简 ORB-SLAM3 Demo,从零实现实时视觉定位
开发语言·python·动态规划
GetcharZp6 小时前
比 Zap 还要快?Go 社区高性能日志神器 Zerolog 落地实践指南
后端
Ulyanov7 小时前
《PySide6 GUI开发指南:QML核心与实践》 第二篇:QML语法精要——构建声明式UI的基础
java·开发语言·javascript·python·ui·gui·雷达电子对抗系统仿真
码界筑梦坊7 小时前
357-基于Java的大型商场应急预案管理系统
java·开发语言·毕业设计·知识分享
anzhxu7 小时前
Go基础之环境搭建
开发语言·后端·golang
刀法如飞7 小时前
一款Python语言Django框架DDD脚手架,适合中大型项目
后端·python·领域驱动设计