像 assert! 一樣,這個宏有第二種形式,可以提供自定義的Panics消息。 例子 let a = 3; let b = 1 + 2; assert_eq!(a, b); assert_eq!(a, b, "we are testing addition with {} and {}", a, b);相關用法 Rust assert_ne用法及代碼示例 Rust assert_m
debug_assert_eq{ ($($arg : tt) *) => { ... }; } 断言两个表达式彼此相等。 Panics时,此宏将打印表达式的值及其调试表示。 与assert_eq!不同,默认情况下debug_assert_eq!语句仅在非优化构建中启用。除非将-C debug-assertions传递给编译器,否则优化的构建将不会执行debug_assert_eq!语句。这使得debu...