Macro enso_shapely::define_singleton_enum_from[][src]

macro_rules! define_singleton_enum_from {
    (
        $(#$meta:tt)*
        $name:ident {
            $( $(#$field_meta:tt)* $field:ident ),* $(,)?
        }
    ) => { ... };
}
Expand description

Defines an associated enum type for predefined singletons.

For the following input:

define_singleton_enum!{
    MyEnum {
        /// A Foo!
        Foo,
        /// A Bar!
        Bar,
    }
}

It expands to:

#[allow(missing_docs)]
#[derive(Copy, Clone, Debug)]
pub enum MyEnum {
    #[doc = r###"A Foo!"###]
    Foo,
    #[doc = r###"A Bar!"###]
    Bar,
}
impl From<Foo> for MyEnum {
    fn from(_: Foo) -> Self {
        Self::Foo
    }
}
impl From<PhantomData<Foo>> for MyEnum {
    fn from(_: PhantomData<Foo>) -> Self {
        Self::Foo
    }
}
impl From<Bar> for MyEnum {
    fn from(_: Bar) -> Self {
        Self::Bar
    }
}
impl From<PhantomData<Bar>> for MyEnum {
    fn from(_: PhantomData<Bar>) -> Self {
        Self::Bar
    }
}