Derive Macro enumcapsulate_macros::FromVariant
source · #[derive(FromVariant)]Expand description
Derive macro generating an impl of the trait FromVariant<T>.
It generates an impl for each of the enum’s
newtype variants, where Inner is the variant’s field type
and Outer is the enclosing enum’s type.
ⓘ
enum Outer {
Inner(Inner),
// ...
}
// The generated impls look something along these lines:
impl FromVariant<Inner> for Outer {
fn from_variant(inner: Inner) -> Self {
Outer::Inner(inner)
}
}
// ...