derive_flat_debug

Crates.ioderive_flat_debug
lib.rsderive_flat_debug
version0.1.0
created_at2025-06-01 06:13:47.288883+00
updated_at2025-06-01 06:13:47.288883+00
descriptionDerive macro for flatter enum debug output
homepagehttps://github.com/cuppachino/derive_flat_debug
repositoryhttps://github.com/cuppachino/derive_flat_debug
max_upload_size
id1696914
size12,385
Jacob Bergholtz (cuppachino)

documentation

README

Derive Flat Debug

This macro generates a custom Debug implementation for enums that:

  • Flattens single-field tuple variants when the variant name matches the field type name or when #[debug(flatten)] is used.
  • Skip flattening variants with #[debug(skip)].

Restrictions:

  • Only applicable to enums (not structs or unions)
  • #[debug(skip)] and #[debug(flatten)] cannot be used together on the same variant

Example usage:

#[derive(DebugFlat, PartialEq)]
pub enum QueryToken {
    #[debug(flatten)] Group(Molecule),
    Molecule(Molecule),
    Atom(Atom),
    #[debug(skip)] Infix(Infix),
    #[debug(skip)] Postfix(Postfix),
    Filter(Filter),
}

#[derive(Debug, PartialEq)]
pub struct Molecule(pub Vec<QueryToken>);
Commit count: 2

cargo fmt