| Crates.io | unwrap-enum |
| lib.rs | unwrap-enum |
| version | 0.1.2 |
| created_at | 2024-05-19 23:52:32.030893+00 |
| updated_at | 2025-10-28 05:40:14.11797+00 |
| description | generate methods to access enum variants |
| homepage | https://github.com/Jturnerusa/unwrap-enum |
| repository | https://github.com/Jturnerusa/unwrap-enum |
| max_upload_size | |
| id | 1245285 |
| size | 43,324 |
A crate to generate methods to unwrap enums as certain variants, like is_some
and is_none on Option.
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));
Implement EnumAsMut and EnumInto derive macros.