unwrap-enum

Crates.iounwrap-enum
lib.rsunwrap-enum
version0.1.0
sourcesrc
created_at2024-05-19 23:52:32.030893
updated_at2024-07-22 00:48:51.292445
descriptiongenerate methods to access enum variants
homepagehttps://github.com/Jturnerusa/unwrap-enum
repositoryhttps://github.com/Jturnerusa/unwrap-enum
max_upload_size
id1245285
size40,781
(Jturnerusa)

documentation

README

unwrap-enum

A crate to generate methods to unwrap enums as certain variants, like is_none and is_none on Option.

Example

use unwrap_enum::{EnumAs, EnumIs};

#[derive(Clone, Debug, EnumAs, EnumIs)]
enum Value {
    String(String),
    Int(i64)
}

let value = Value::String("hello world".to_string());

assert!(value.is_string());
assert!(!value.is_int());
assert!(matches!(value.as_string(), Some(string) if string == "hello world"));
assert!(matches!(value.as_int(), None));

Todo

Implement EnumAsMut and EnumInto derive macros.

Commit count: 42

cargo fmt