Assure: macros for Rust runtime checks and error handling
This Rust crate provides the macro assure!
and its friends. These are similar to the macro assert!
and its friends.
-
assure!(condition)
will returnResult
withOk(true)
orErr(message)
. -
assert!(condition)
will return successfully or will callpanic!
.
Macro for truth checking:
assure!(a)
: assurea
is true.
Macros for value comparison:
-
assure_eq!(a, b)
: assurea
is equal tob
. -
assure_ne!(a, b)
: assurea
is not equal tob
. -
assure_lt!(a, b)
: assurea
is less thanb
. -
assure_le!(a, b)
: assurea
is less than or equal tob
. -
assure_gt!(a, b)
: assurea
is greater thanb
. -
assure_ge!(a, b)
: assurea
is greater than or equal tob
.
Macros for iterator sets, such as arrays and vectors:
-
assure_set_eq(a, b)
: assure the seta
is equal to the setb
. -
assure_set_ne(a, b)
: assure the seta
is not equal to the setb
.
Macro for IO-related truth checking, which returns Err(std::io::Error(…))
:
assure_io!(a)
: assurea
is true.
Macros for IO-related value comparison, which returns Err(std::io::Error(…))
:
assure_io_eq!(a, b)
: assurea
is equal tob
.