像 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_matches用法及代碼示例 Rust assert用法及...
Rust debug_assert_eq用法及代码示例本文简要介绍rust语言中 Macro std::debug_assert_eq 的用法。 用法 macro_rules! debug_assert_eq { ($($arg : tt) *) => { ... }; } 断言两个表达式彼此相等。 Panics时,此宏将打印表达式的值及其调试表示。 与 assert_eq! 不同,默认情况下 debug_assert_eq!