Function std::revert::require

pub fn require<T>(condition: bool, value: T) 
Expand description

Checks if the given condition is true and if not, logs value and reverts.

Arguments

  • condition: [bool] - The condition upon which to decide whether to revert or not.
  • value: [T] - The value which will be logged in case condition is false.

Reverts

  • Reverts when condition is false.

Examples

fn foo(a: u64, b: u64) {
    require(a == b, "a was not equal to b");
    // If the condition was true, code execution will continue
    log("The require function did not revert");
}