enum_variant_eq

Crates.ioenum_variant_eq
lib.rsenum_variant_eq
version0.1.0
sourcesrc
created_at2023-03-24 15:00:44.904532
updated_at2023-03-24 15:00:44.904532
descriptionDetermining that enumerations only have Variant equal
homepagehttps://github.com/A4-Tacks/rust-enum_variant_eq
repositoryhttps://github.com/A4-Tacks/rust-enum_variant_eq
max_upload_size
id819345
size6,577
A4-Tacks (A4-Tacks)

documentation

README

Determining that enumerations only have Variant equal

Examples

use enum_variant_eq::{*,enum_variant_eq_derive::*};

#[derive(Debug, EnumVariantEq)]
enum TestEnum {
    Unit,
    EmptyUnNamed(),
    UnNamed(i8),
    UnNamed2(i8, u8),
    EmptyNamed {},
    Named { x: i8 },
    Named2 { x: i8, y: u8 },
}
use TestEnum::*;
assert!(Unit.enum_variant_eq(&Unit));
assert!(UnNamed(5).enum_variant_eq(&UnNamed(8)));
assert!(Named { x: 5 }.enum_variant_eq(&Named { x: 8 }));

Errors

EnumVariantEq only applies to enumerations. If it is violated, the compilation will panic

#[derive(EnumVariantEq)]
struct S;
error: #[derive(Debug, EnumVariantEq)]
    |                  ^^^^^^^^^^^^^
    = help: message: Type Is Not Enum

Other:

Build Ast Error

Commit count: 15

cargo fmt