Macro std::assert_eq

1.0.0 · source ·
macro_rules! assert_eq {
    ($left:expr, $right:expr $(,)?) => { ... };
    ($left:expr, $right:expr, $($arg:tt)+) => { ... };
}
Expand description

断言两个表达式彼此相等 (使用 PartialEq)。

在 panic 上,此宏将打印表达式的值及其调试表示。

assert! 一样,此宏具有第二种形式,可以在其中提供自定义 panic 消息。

Examples

let a = 3;
let b = 1 + 2;
assert_eq!(a, b);

assert_eq!(a, b, "we are testing addition with {} and {}", a, b);
Run