https://github.com/artichoke/qed
∎ Compile-time assertion macros
https://github.com/artichoke/qed
artichoke assert compile-time const-assert no-std rust rust-crate
Last synced: about 1 month ago
JSON representation
∎ Compile-time assertion macros
- Host: GitHub
- URL: https://github.com/artichoke/qed
- Owner: artichoke
- License: mit
- Created: 2022-04-09T19:47:03.000Z (over 3 years ago)
- Default Branch: trunk
- Last Pushed: 2025-08-26T00:02:35.000Z (about 2 months ago)
- Last Synced: 2025-08-26T02:25:49.146Z (about 2 months ago)
- Topics: artichoke, assert, compile-time, const-assert, no-std, rust, rust-crate
- Language: Rust
- Homepage: https://crates.io/crates/qed
- Size: 1.82 MB
- Stars: 7
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# qed
[](https://github.com/artichoke/qed/actions)
[](https://discord.gg/QCe2tp2)
[](https://twitter.com/artichokeruby)
[](https://crates.io/crates/qed)
[](https://docs.rs/qed)
[](https://artichoke.github.io/qed/qed/)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`:
```toml
[dependencies]
qed = "1.6.1"
```Then make compile time assertions like:
```rust
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`].
[`core`]: https://doc.rust-lang.org/stable/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](LICENSE) (c) Ryan Lopopolo.