Rust 程序设计语言 简体中文版 1.85.0kind() { ErrorKind::NotFound => match File::create("hello.txt") { Ok(fc) => fc, Err(e) => panic!("Problem creating the file: {e:?}"), }, 175/562Rust assert_eq!(result, 4); 222/562Rust 程序设计语言 简体中文版 } #[test] fn another() { panic!("Make this test fail"); } } 示例 11-3:增加第二个因调用了 panic! 而失败的测试 再次 cargo test 运行测试。输出应该看起来像示例 11-4,它表明 failures: ---- tests::another stdout ---- thread 'tests::another' panicked at src/lib.rs:17:9: Make this test fail note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace failures:0 码力 | 562 页 | 3.23 MB | 25 天前3
共 1 条
- 1













