知识卡片
固定地址契约服务地址敏感对象
Pin围住的是指针,约束其目标在地址敏感期间保持位置和有效性;不是把指针变量本身钉死。它为某些自引用和异步状态机提供共同契约,Unpin等条件会影响限制。构造与使用unsafe部分仍须维护不变量,Pin不是自动修复任意内部引用的魔法。
限定依据:std::pin官方说明,2026-10-27读取定义与地址敏感模型。
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- Chapter 3. Concepts Self-referential data structures · 查看原书依据
Pin type in the standard library. This pointer type “pins” its value in place, forcing the value to remain at the same location in memory, thus ensuring that internal self-references remain valid. So Pin is available as a possibility for self-referential types, but it’s tricky to use correctly—be sure to read the official docs. Where possible, avoid self-ref
参考来源
- 位置:《Effective Rust 35 Specific Ways to Improve Your Rust Code (David Drysdale)》第3章《Self-referential data structures》(spine7;extracted/Effective Rust 35 Specific Ways to Improve Your Rust Code (David Drysdale)/_epub-src/OEBPS/ch03.html;u096-ch03-025)。
- 结论依据:原文在“Pin type”附近的定义、例子或代码支撑本卡核心说明:Pin<Ptr>围住的是指针,约束其目标在地址敏感期间保持位置和有效性;不是把指针变量本身钉死。边界按已读前提解释;示例未执行。
- 原始内容:Pin type in the standard library. This pointer type “pins” its value in place, forcing the value to remain at the same location in memory, thus ensuring that internal self-references remain valid. So Pin is available as a possibility for self-referential types, but it’s tricky to use correctly—be sure to read the official docs. Where possible, avoid self-ref