Crates.io | enum_variant_eq |
lib.rs | enum_variant_eq |
version | 0.1.0 |
source | src |
created_at | 2023-03-24 15:00:44.904532 |
updated_at | 2023-03-24 15:00:44.904532 |
description | Determining that enumerations only have Variant equal |
homepage | https://github.com/A4-Tacks/rust-enum_variant_eq |
repository | https://github.com/A4-Tacks/rust-enum_variant_eq |
max_upload_size | |
id | 819345 |
size | 6,577 |
Determining that enumerations only have Variant equal
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 }));
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
Build Ast Error