assert!() { /* proc-macro */ }Expand description
The main macro that is used to check a condition and panic if it is false.
§Syntax
assert!(condition: expression);
assert!(condition: expression, message: format_string, args...: format_args);Parameters:
condition: The condition that should be checked. If it evaluates tofalse, the assertion fails. Can be any expression that evaluates tobool.message: An optional message that is displayed if the assertion fails. This message can contain{}placeholders for dynamic arguments. Seeformat_argsfor more information.args: Arguments that are only evaluated if the assertion fails. These arguments are passed toformat_argsto replace the{}placeholders in the message.
§Examples
See the crate-level documentation for examples.