4.1 常见前置条件
常见前置条件 — Comprehensive Rust
1分钟内可阅读完
译文 · 基于 Comprehensive Rust
原文链接: https://google.github.io/comprehensive-rust/unsafe-deep-dive/safety-preconditions.html
安全前置条件是指:某项操作在执行前必须满足的条件,满足后该操作才是安全的。
「安全前置条件是指代码上必须满足的条件,以维持 Rust 的安全保证。
「你很可能会发现,安全前置条件与 Safe Rust 的规则之间有很强的对应关系。」
问:「你能列举一些吗?」
(更完整的列表在下一页幻灯片)
常见前置条件 — Comprehensive Rust
语义前置条件 — Comprehensive Rust
确定前置条件 — Comprehensive Rust
定义自己的前置条件 — Comprehensive Rust