Crates.io | enum_helpers |
lib.rs | enum_helpers |
version | 0.0.4 |
source | src |
created_at | 2023-06-16 18:16:21.470877 |
updated_at | 2023-06-19 21:53:24.363713 |
description | Adds functions like is_, as_, as_mut_ and into_ to enums |
homepage | |
repository | https://github.com/crwn1337/enum_helpers |
max_upload_size | |
id | 892496 |
size | 16,719 |
A Rust library to add helper functions to enums, with methods such as is_
, as_
, as_mut_
, and into_
, allowing you to simply your codebase and improve code readability.
The following example demonstrates the usage of the EnumIs
derive macro to utilize a simpler type checking for enums.
use enum_helpers::EnumIs;
#[derive(EnumIs)]
pub enum Test {
Example(u32),
}
pub fn main() {
let test = Test::Example(123);
assert!(test.is_example()); // true
}
For more examples, refer to the tests directory.
To keep up with the latest features, improvements, and bug fixes, refer to the Changelog file.