Expand description
§assert-order
Assert the definition order of enum variants.
§Why?
The main motivation is that plenty of serialization formats are not self-describing, which means that for enums, in particular, reordering enum variants can result in de/serialization errors.
This crate allows you to assert the order of enum variants, which can help prevent accidental reordering.
§Example
use assert_order::{VariantOrder, assert_order};
#[derive(VariantOrder)]
enum TestEnum {
A,
B(),
C {},
}
assert_order::<TestEnum, _, _>(["A", "B", "C"]);Traits§
- Variant
Order - Trait for getting the canonical ordering of an enum’s variants.
Functions§
- assert_
order - Assert the ordering of some enum implementing VariantOrder.
Derive Macros§
- Variant
Order - Derive macro for implementing
VariantOrderbased on the definition of an enum.