Rust 为什么测试失败,并显示消息“测试失败”;对盒子感到恐慌<;任何>&引用;?
为什么会这样恐慌Rust 为什么测试失败,并显示消息“测试失败”;对盒子感到恐慌<;任何>&引用;?,rust,panic,Rust,Panic,为什么会这样恐慌 pub fn testbool() -> bool { vec!['a', 'd', 'i', 'e', 'p', 'r'] .iter() .enumerate() .find(|(_i, &c)| c != 'c') .is_none() } #[test] fn test_testbool() { assert!(testbool(), true); } ----test\
pub fn testbool() -> bool {
vec!['a', 'd', 'i', 'e', 'p', 'r']
.iter()
.enumerate()
.find(|(_i, &c)| c != 'c')
.is_none()
}
#[test]
fn test_testbool() {
assert!(testbool(), true);
}
----test\u testbool标准输出----
线程“test\u testbool”在“Box”处惊慌失措,src/lib.rs:11:5
注意:使用'RUST_BACKTRACE=1'环境变量运行以显示回溯。
它可能很简单,但我不明白。您正在使用。这要求第一个参数是布尔表达式。任何后续参数都被视为格式字符串,并且其参数为:
assert!(testbool(), "Did not work: {}", 42);
线程“test\u testbool”恐慌于“未工作:42”
您可能希望删除assert的第二个参数代码>或切换到
我相信根问题来自于允许非格式字符串在某些情况下用作格式字符串的