enum-procs

Crates.ioenum-procs
lib.rsenum-procs
version0.3.0
sourcesrc
created_at2024-04-15 11:13:15.064862
updated_at2024-08-03 08:50:00.870896
descriptionUseful enum macros.
homepage
repositoryhttps://github.com/artegoser/enum-procs
max_upload_size
id1209132
size7,617
Artemy Egorov (artegoser)

documentation

README

enum-procs

Useful enum macros

crates.io

AutoFrom

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()));

PartialEqVariant

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));
Commit count: 4

cargo fmt