7 releases (stable)

Uses new Rust 2021

1.4.0 Apr 27, 2022
1.3.1 Apr 19, 2022
0.0.0 Apr 8, 2022

#422 in Rust patterns

Download history 258/week @ 2022-06-03 139/week @ 2022-06-10 257/week @ 2022-06-17 757/week @ 2022-06-24 318/week @ 2022-07-01 135/week @ 2022-07-08 172/week @ 2022-07-15 273/week @ 2022-07-22 583/week @ 2022-07-29 353/week @ 2022-08-05 343/week @ 2022-08-12 295/week @ 2022-08-19 456/week @ 2022-08-26 1028/week @ 2022-09-02 802/week @ 2022-09-09 231/week @ 2022-09-16

2,561 downloads per month

MIT license

23KB
324 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.4.0"

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 although some macros may construct types which require ::std to be available.

Minimum Supported Rust Version

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

License

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

No runtime deps