TryInto

Derive Macro TryInto 

Source
#[derive(TryInto)]
{
    // Attributes available to this derive:
    #[convert_enum]
}
Expand description

Automatically generate reverse TryFrom implementations for enum variants, ignore ones marked #[convert_enum(optout)].

All variants not affected by the opt-out must be tuple-like variants with exactly one field. A variant of the form E::V(T) will cause the generation of the following code:

impl TryFrom<E> for T {
    type Error = E;

    fn try_from(val: E) -> Result<T, E> {
        match val {
            E::V(val) => Ok(val),
            _ => Err(val),
        }
    }
}