assert-order 0.0.1

Assert the order of Rust enum variants.
Documentation

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"]);