GitHub - nvzqz/static-assertions: Ensure correct assumptions about constants, types, and more in Rust (original) (raw)

Banner

Crates.io Downloads Build Status rustc ^1.37.0
Become a Patron! Buy me a coffee

Compile-time assertions for Rust, brought to you byNikolai Vazquez.

This library lets you ensure correct assumptions about constants, types, and more. See the docs and FAQ for more info!

Installation

This crate is availableon crates.io and can be used by adding the following to your project'sCargo.toml:

[dependencies] static_assertions = "1.1.0"

and this to your crate root (main.rs or lib.rs):

#[macro_use] extern crate static_assertions;

Usage

This crate exposes the following macros:

FAQ

#[cfg(test)]
const_assert_eq!(MEANING_OF_LIFE, 42);
However, the assertions will only be checked when running cargo test. This somewhat defeats the purpose of catching false static conditions up-front with a compilation failure.

Changes

See CHANGELOG.mdfor a complete list of what has changed from one version to another.

License

This project is released under either:

at your choosing.