Question : assert_eq rust
Answered by : taylor-0dyteg295lqr
// The assert_eq! macro is used to check if 2 expressions are equal.
// source: https://doc.rust-lang.org/std/macro.assert_eq.html
// This macro is commonly used in testing. See more: https://doc.rust-lang.org/book/ch11-01-writing-tests.html
// For example;
let a = 3;
let b = 1 + 2;
assert_eq!(a, b);
assert_eq!(a, b, "we are testing addition with {} and {}", a, b);
// There is also the assert_ne! macro to check if 2 expressions are not equal.
// source: https://doc.rust-lang.org/std/macro.assert_ne.html
// For example;
let a = 3;
let b = 2;
assert_ne!(a, b);
assert_ne!(a, b, "we are testing that the values are not equal");
Source : https://doc.rust-lang.org/std/macro.assert_eq.html | Last Update : Sun, 13 Mar 22