Rust 程序设计语言 简体中文版 1.85.03; if number != 0 { println!("number was something other than zero"); } } 运行代码会打印出 number was something other than zero。 使用 else if 处理多重条件 可以将 else if 表达式与 if 和 else 组合来实现多重条件。例如: 文件名:src/main Compiling ownership v0.1.0 (file:///projects/ownership) error[E0499]: cannot borrow `s` as mutable more than once at a time --> src/main.rs:5:14 | 4 | let r1 = &mut s; | ------ first mutable } } #[cfg(test)] mod tests { use super::*; #[test] #[should_panic] fn greater_than_100() { 231/562Rust 程序设计语言 简体中文版 Guess::new(200); } } 示例 11-8:测试会造成 panic! 的条件 #[should_panic]0 码力 | 562 页 | 3.23 MB | 24 天前3
共 1 条
- 1













