pub fn parse_attrs_to_name_value(
    attr: &Attribute,
    message: &str,
) -> ParseAttrResult<Vec<MetaNameValue>> {
    let mut mnvs: Vec<MetaNameValue> = vec![];

    match attr.parse_meta() {
        Err(e) => return Err(e.to_compile_error()),
        Ok(Meta::List(list)) => {
            for nestedmeta in list.nested {
                match nestedmeta {
                    NestedMeta::Meta(Meta::NameValue(mnv)) => {
                        mnvs.push(mnv);
                    }
                    _ => {
                        return Err(
                            SynError::new(attr.span(), message.to_owned()).to_compile_error()
                        )
                    }
                }
            }
        }
        Ok(_) => return Err(SynError::new(attr.span(), message.to_owned()).to_compile_error()),
    }

    Ok(mnvs)
}
// Helps cut through a lot of parse tree and doesn't confuse reading-context
Helps cut through a lot of parse tree and doesn't confuse reading-context
Helps cut through a lot of parse tree and doesn ' t confuse reading - context
pub fn parse_attrs_to_name_value(
    attr: &Attribute,
    message: &str,
) -> ParseAttrResult<Vec<MetaNameValue>> {
    let mut mnvs: Vec<MetaNameValue> = vec![];
    match attr.parse_meta() {
        Err(e) => return Err(e.to_compile_error()),
        Ok(Meta::List(list)) => {
            for nestedmeta in list.nested {
                match nestedmeta {
                    NestedMeta::Meta(Meta::NameValue(mnv)) => {
                        mnvs.push(mnv);
                    }
                    _ => {
                        return Err(
                            SynError::new(attr.span(), message.to_owned()).to_compile_error()
                        )
                    }
                }
            }
        }
        Ok(_) => return Err(SynError::new(attr.span(), message.to_owned()).to_compile_error()),
    }
    Ok(mnvs)
}
pub fn parse_attrs_to_name_value ( attr : & Attribute , message : & str , ) -> ParseAttrResult < Vec < MetaNameValue > > { let mut mnvs : Vec < MetaNameValue > = vec ! [ ] ; match attr . parse_meta ( ) { Err ( e ) => return Err ( e . to_compile_error ( ) ) , Ok ( Meta :: List ( list ) ) => { for nestedmeta in list . nested { match nestedmeta { NestedMeta :: Meta ( Meta :: NameValue ( mnv ) ) => { mnvs . push ( mnv ) ; } _ => { return Err ( SynError :: new ( attr . span ( ) , message . to_owned ( ) ) . to_compile_error ( ) ) } } } } Ok ( _ ) => return Err ( SynError :: new ( attr . span ( ) , message . to_owned ( ) ) . to_compile_error ( ) ) , } Ok ( mnvs ) }
Helps cut through a lot of parse tree and doesn't confuse reading-context
Helps cut through a lot of parse tree and doesn ' t confuse reading - context
attr
&Attribute
message
&str