#assert #debug-assert #debug #assertions #testing

more-asserts

Small library providing additional assert_* and debug_assert_* macros

4 releases

Uses old Rust 2015

0.2.2 Nov 17, 2021
0.2.1 May 23, 2018
0.2.0 May 23, 2018
0.1.0 Jun 18, 2016

#50 in Rust patterns

Download history 34686/week @ 2021-09-26 33089/week @ 2021-10-03 35342/week @ 2021-10-10 36767/week @ 2021-10-17 33898/week @ 2021-10-24 33211/week @ 2021-10-31 36277/week @ 2021-11-07 40030/week @ 2021-11-14 33844/week @ 2021-11-21 49933/week @ 2021-11-28 73707/week @ 2021-12-05 72456/week @ 2021-12-12 56326/week @ 2021-12-19 39022/week @ 2021-12-26 72384/week @ 2022-01-02 80220/week @ 2022-01-09

252,547 downloads per month
Used in 218 crates (49 directly)

CC0 license

17KB
195 lines

More Asserts (for Rust).

Docs

Small library providing assertion macros similar to the {debug_,}assert_{eq,ne} macros in the stdlib.

Usage

  1. Add more-asserts = "0.2" to your Cargo.toml.
  2. Add #[macro_use] extern crate more_asserts to 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 arguments
  • assert_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 of assert_lt! controlled by cfg!(debug_assertions).
  • debug_assert_gt!(left, right): Variant of assert_gt! controlled by cfg!(debug_assertions).
  • debug_assert_le!(left, right): Variant of assert_le! controlled by cfg!(debug_assertions).
  • debug_assert_ge!(left, right): Variant of assert_ge! controlled by cfg!(debug_assertions).
  • debug_unreachable!(...): Variant of the standard library's unreachable! that is controlled by cfg!(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.

License

CC0 (public domain).

No runtime deps