Function std::revert::revert

pub fn revert(code: u64) -> ! 
Expand description

Will either panic or revert with a given number depending on the context.

Additional Information

If used in a predicate, it will panic.
If used in a contract, it will revert.

Arguments

  • code: [u64] - The code with which to revert the program.

Reverts

  • Reverts unconditionally.

Examples

fn foo(should_revert: bool) {
    match should_revert {
        true => revert(0),
        false => {},
    }
}