属性宏
含义
作用
#[cfg(test)]
把 #[cfg(test)] 标注的那段代码标记为「仅在测试编译时才有」的代码。
这段代码只在 cargo test 编译时才存在,正常 cargo build / cargo run 时被完全忽略。