Trait GetVariant

Source
pub trait GetVariant<T, Marker> {
    // Required methods
    fn get_variant(self) -> Result<T, EnumConversionError>;
    fn get_variant_ref(&self) -> Result<&T, EnumConversionError>;
    fn get_variant_mut(&mut self) -> Result<&mut T, EnumConversionError>;
}
Expand description

This is a helper trait for implementing the TryTo and std::convert::TryFrom traits on enums. Is uses marker structs to uniquely identify a type in the enum. This avoids relying on std::any::TypeId which is limited to types that are 'static.

Required Methods§

Implementors§