assert_eq
The assert_eq
function is automatically imported into every program from the prelude. It takes two expressions which are compared and the result is a Boolean. If the value is false
then the virtual machine will revert.
Example
Here is a function which asserts that a
and b
must be equal.
fn compare_eq(a: u64, b: u64) {
assert_eq(a, b);
// code
}