macro_rules! with_error {
(
$(#[$enum_meta:meta])*
$enum_vis:vis enum $enum_name:ident {
$(
$(#[$variant_meta:meta])*
$variant_name:ident = $string:literal $(| $alias:literal)* $(= $discriminant:expr)?
),* $(,)?
}
throws
$(#[$error_meta:meta])*
$error_name:ident $(;)?
) => { ... };
}Expand description
Like strum!, but also declares a custom zero-sized error type,
rather than using the pointer-wide ParseError.
The error type will implement Debug,
Display, and Error,
as well as custom derives.
strum_lite::with_error! {
#[derive(Default)]
pub enum Casing {
Kebab = "kebab-case" | "kebab",
#[default]
ScreamingSnake = "SCREAMING_SNAKE",
}
throws #[derive(Default)] ParseCasingError;
}See crate documentation for more.
You are encouraged to copy-paste this macro into your own code.