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

more-asserts

Small library providing additional assert_* and debug_assert_* macros

6 releases

0.3.1 Oct 1, 2022
0.3.0 Jun 3, 2022
0.2.2 Nov 17, 2021
0.2.1 May 23, 2018
0.1.0 Jun 18, 2016

#88 in Rust patterns

Download history 84626/week @ 2024-11-15 77889/week @ 2024-11-22 83297/week @ 2024-11-29 86428/week @ 2024-12-06 79026/week @ 2024-12-13 43671/week @ 2024-12-20 42319/week @ 2024-12-27 84143/week @ 2025-01-03 126727/week @ 2025-01-10 91288/week @ 2025-01-17 101079/week @ 2025-01-24 102456/week @ 2025-01-31 103055/week @ 2025-02-07 94899/week @ 2025-02-14 114277/week @ 2025-02-21 89926/week @ 2025-02-28

424,164 downloads per month
Used in 531 crates (124 directly)

Unlicense OR MIT OR Apache-2…

17KB
229 lines

More Asserts (for Rust).

Docs Latest Version Minimum Rust Version

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

Usage

use more_asserts as ma;

#[derive(Debug, PartialEq, PartialOrd)]
enum Example { Foo, Bar }

ma::assert_le!(3, 4);
ma::assert_ge!(
    10, 10,
    "You can pass a message too (just like `assert_eq!`)",
);
ma::debug_assert_lt!(
    1.3, 4.5,
    "Format syntax is supported ({}).",
    "also like `assert_eq!`"
);

ma::assert_gt!(
    Example::Bar, Example::Foo,
    "It works on anything that implements PartialOrd and Debug!",
);

License

Public domain as explained by either the Unlicense or CC0. If neither of these are acceptable, you can also choose use it under the MIT/Apache2 combo typical of Rust code.

Yes, this is a lot. It was originally just "public domain as explained by CC0" (since CC0 was the public domain-alike license preferred by lawyers), but then CC0 fell out of favor, so I added the others as alternatives: Unlicense as a (hopefully) better public domain analogue, and MIT/Apache2 since (I know some folks dislike the Unlicense and) Rust will implode if those ever become a problem.

No runtime deps