Macro bp3d_util::simple_error
source · macro_rules! simple_error { ( $(#[$meta: meta])* $vis: vis $name: ident { $( $(#[$field_meta: meta])* $((impl $e: ident))? $ty: ident $(($data: ty))? => $desc: literal ),* } ) => { ... }; }
Available on crate feature
simple-error only.Expand description
Generates a simple enum which maps multiple error types and implements Error and Display automatically. This optionally can generate From implementations on demand.
§Example
use bp3d_util::simple_error;
simple_error!(
/// Doc.
TestError {
/// This is a doc comment which is recorded by the macro.
Untyped => "untyped variant",
/// Another doc comment.
(impl From) Io(std::io::Error) => "io error {}",
Other(u8) => "other u8 error {}"
}
);
println!("{}", TestError::Untyped);