More Asserts (for Rust).
Small library providing assertion macros similar to the {debug_,}assert_{eq,ne} macros in the stdlib.
Usage
- Add
more-asserts = "0.2"to yourCargo.toml. - Add
#[macro_use] extern crate more_assertsto your code.
After this, the following macros are available in your code (see the documentation for more info):
assert_lt!(left, right): Panics if!(left < right). Optionally can take format argumentsassert_gt!(left, right): Panics if!(left > right).assert_le!(left, right): Panics if!(left <= right).assert_ge!(left, right): Panics if!(left >= right).debug_assert_lt!(left, right): Variant ofassert_lt!controlled bycfg!(debug_assertions).debug_assert_gt!(left, right): Variant ofassert_gt!controlled bycfg!(debug_assertions).debug_assert_le!(left, right): Variant ofassert_le!controlled bycfg!(debug_assertions).debug_assert_ge!(left, right): Variant ofassert_ge!controlled bycfg!(debug_assertions).debug_unreachable!(...): Variant of the standard library'sunreachable!that is controlled bycfg!(debug_assertations).
Note that assert_eq!, assert_ne!, debug_assert_eq!, and debug_assert_ne! are not provided, as those are in the standard library.