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!.
Macros for simple values
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 set comparison
These macros help with order-independent comparison of iterator set parameters, such as comparison of two arrays, or two 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 checking
These macros help with IO-related checking, such as comparison of files, streams, etc. These macros return a Result with Ok(true) or Err(std::io::Error(…)).
Macro for truth checking:
assure_io!(a): assureais true.
Macros for value comparison:
-
assure_io_eq!(a, b): assureais equal tob. -
assure_io_ne!(a, b): assureais not equal tob. -
assure_io_lt!(a, b): assureais less thanb. -
assure_io_le!(a, b): assureais less than or equal tob. -
assure_io_gt!(a, b): assureais greater thanb. -
assure_io_ge!(a, b): assureais greater than or equal tob.