Crates.io | enum-procs |
lib.rs | enum-procs |
version | 0.3.0 |
source | src |
created_at | 2024-04-15 11:13:15.064862 |
updated_at | 2024-08-03 08:50:00.870896 |
description | Useful enum macros. |
homepage | |
repository | https://github.com/artegoser/enum-procs |
max_upload_size | |
id | 1209132 |
size | 7,617 |
Useful enum macros
Derive macro generating an impl of the trait From
for all types
inside tuple variants with one type
use enum_procs::AutoFrom;
#[derive(AutoFrom, Debug, PartialEq, Eq)]
enum Test {
Bool(bool),
Text(String),
}
assert_eq!(Test::from(true), Test::Bool(true));
assert_eq!(Test::from("Test"), Test::Text("Test".to_owned()));
Derive macro generating an impl of the trait PartialEq
that compare enum only by variant
use enum_procs::PartialEqVariant;
#[derive(PartialEqVariant, Eq)]
enum EnumProc {
VariantWithValue(bool),
AnotherVariantWithValue(bool),
}
assert!(EnumProc::VariantWithValue(true) == EnumProc::VariantWithValue(false));
assert!(EnumProc::VariantWithValue(false) == EnumProc::VariantWithValue(true));