const-exhaustive
Enumerate all values of a type at compile time.
Features
-
All values of
T: Exhaustiveare stored in aGenericArray- allowing you to access all values at compile time, and in a const context. -
Composable with
coretypes - supports[T; N], tuples up to arity 16,Option<T>, and other types incore. -
#[derive(Exhaustive)]- to implement it on your own types. -
#![no_std]and noalloc- you can use it anywhere.
Examples
use Exhaustive;
// there is 1 value of `()`
assert_eq!;
// there are 2 values of `bool`
assert_eq!;
// works on types with generics
assert_eq!;
// write your own exhaustive types
assert_eq!;
// works on arbitrarily complex types
Testing
Run unit and doc tests:
Run miri tests:
Test generating docs:
RUSTDOCFLAGS="--cfg docsrs_dep"