pub fn emit_try_from(
    imp: &syn::ImplGenerics,
    ident: &TokenStream,
    wher: Option<&syn::WhereClause>,
) -> TokenStream {
    quote! {
        impl #imp core::convert::TryFrom<&[u8]> for #ident #wher {
            type Error = DekuError;

            fn try_from(input: &[u8]) -> Result<Self, Self::Error> {
                let (rest, res) = Self::from_bytes((input, 0))?;
                if !rest.0.is_empty() {
                    return Err(DekuError::Parse(format!("Too much data")));
                }
                Ok(res)
            }
        }
    }
}
/// emit `TryFrom` trait for struct/enum
emit `TryFrom` trait for struct/enum
emit ` TryFrom ` trait for struct / enum
pub fn emit_try_from(
    imp: &syn::ImplGenerics,
    ident: &TokenStream,
    wher: Option<&syn::WhereClause>,
) -> TokenStream {
    quote! {
        impl #imp core::convert::TryFrom<&[u8]> for #ident #wher {
            type Error = DekuError;
            fn try_from(input: &[u8]) -> Result<Self, Self::Error> {
                let (rest, res) = Self::from_bytes((input, 0))?;
                if !rest.0.is_empty() {
                    return Err(DekuError::Parse(format!("Too much data")));
                }
                Ok(res)
            }
        }
    }
}
pub fn emit_try_from ( imp : & syn :: ImplGenerics , ident : & TokenStream , wher : Option < & syn :: WhereClause > , ) -> TokenStream { quote ! { impl imp core convert TryFrom [ u8 ] for ident wher { type Error DekuError fn try_from ( input [ u8 ] ) Result Self Self Error { let ( rest res ) Self from_bytes ( ( input 0 ) ) if rest 0 is_empty ( ) { return Err ( DekuError Parse ( format ( " " ) ) ) } Ok ( res ) } } } }
emit `TryFrom` trait for struct/enum
emit ` TryFrom ` trait for struct / enum
imp
&syn::ImplGenerics
ident
&TokenStream
wher
Option<&syn::WhereClause>
imp
&syn::ImplGenerics
ident
&TokenStream
wher
Option<&syn::WhereClause>