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 returnResultwithOk(true)orErr(message). -
assert!(condition)will return successfully or will callpanic!.
Macro for truth checking:
assure!(a): assureais true.
Macros for value comparison:
-
assure_eq!(a, b): assureais equal tob. -
assure_ne!(a, b): assureais not equal tob. -
assure_lt!(a, b): assureais less thanb. -
assure_le!(a, b): assureais less than or equal tob. -
assure_gt!(a, b): assureais greater thanb. -
assure_ge!(a, b): assureais greater than or equal tob.
Macros for iterator sets, such as arrays and vectors:
-
assure_set_eq(a, b): assure the setais equal to the setb. -
assure_set_ne(a, b): assure the setais not equal to the setb.
Macros for IO-related truth checking, which returns Err(std::io::Error(…)):
assure_io!(a): assureais true.