知识卡片
共享与独占借用不能冲突
对同一位置,活跃共享借用可有多个,独占可变借用则排斥冲突共享或可变访问;引用还不能超出目标有效期。两个&mut参数不能同时指向同一对象。规则限制别名与数据竞争,但内部可变性有受控机制,业务层多步骤竞态也仍需设计。
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- Chapter 3. Concepts Borrow Rules · 查看原书依据
Borrow Rules There are two key rules to remember when borrowing references in Rust. The first rule is that the scope of any reference must be smaller than the lifetime of the item that it refers to. Lifetimes are explored in detail in Item 14, but it’s worth noting that the compiler has special behavior for reference lifetimes; the non-lexical lifetimes feat
参考来源
- 位置:《Effective Rust 35 Specific Ways to Improve Your Rust Code (David Drysdale)》第3章《Borrow Rules》(spine7;extracted/Effective Rust 35 Specific Ways to Improve Your Rust Code (David Drysdale)/_epub-src/OEBPS/ch03.html;u090-ch03-014)。
- 结论依据:原文在“Borrow Rules”附近的定义、例子或代码支撑本卡核心说明:对同一位置,活跃共享借用可有多个,独占可变借用则排斥冲突共享或可变访问;引用还不能超出目标有效期。边界按已读前提解释;示例未执行。
- 原始内容:Borrow Rules There are two key rules to remember when borrowing references in Rust. The first rule is that the scope of any reference must be smaller than the lifetime of the item that it refers to. Lifetimes are explored in detail in Item 14, but it’s worth noting that the compiler has special behavior for reference lifetimes; the non-lexical lifetimes feat