9 stable releases

1.6.1 Jun 2, 2023
1.6.0 Apr 20, 2023
1.4.0 Apr 27, 2022
0.0.0 Apr 8, 2022

#652 in Rust patterns

Download history 196/week @ 2023-11-04 200/week @ 2023-11-11 184/week @ 2023-11-18 359/week @ 2023-11-25 265/week @ 2023-12-02 182/week @ 2023-12-09 260/week @ 2023-12-16 423/week @ 2023-12-23 319/week @ 2023-12-30 299/week @ 2024-01-06 231/week @ 2024-01-13 307/week @ 2024-01-20 396/week @ 2024-01-27 204/week @ 2024-02-03 242/week @ 2024-02-10 503/week @ 2024-02-17

1,366 downloads per month

MIT license

24KB
322 lines

qed

GitHub Actions Discord Twitter
Crate API API trunk

Compile time assertions.

QED is an initialism of the Latin phrase quod erat demonstrandum, meaning "which was to be demonstrated".

This crate contains compile time assertion macros used for maintaining safety invariants or limiting platform support. If the assertion is false, a compiler error is emitted.

Usage

Add this to your Cargo.toml:

[dependencies]
qed = "1.6.1"

Then make compile time assertions like:

use core::num::NonZeroU8;

qed::const_assert!(usize::BITS >= u32::BITS);
qed::const_assert_eq!("Veni, vidi, vici".len(), 16);
qed::const_assert_ne!(''.len_utf8(), 1);
qed::const_assert_matches!(NonZeroU8::new(42), Some(nz) if nz.get() == 42);

no_std

qed is no_std compatible and all macros only require core.

Minimum Supported Rust Version

This crate requires at least Rust 1.64.0. This version can be bumped in minor releases.

License

qed is licensed under the MIT License (c) Ryan Lopopolo.

No runtime deps