pub(crate) fn parse_attributes(
    attrs: TokenStream,
) -> (Vec<Expr>, Vec<TokenStream>, Option<String>) {
    let segments = segment_input(attrs);
    let mut segments_stream: Vec<TokenStream> = segments
        .iter()
        .map(|x| x.iter().cloned().collect::<TokenStream>())
        .collect();
    let rewritten_segs: Vec<_> = segments.into_iter().map(rewrite).collect();

    let mut conds: Vec<Expr> = vec![];

    for seg in rewritten_segs {
        let expr = match syn::parse2::<Expr>(seg) {
            Ok(val) => val,
            Err(err) => Expr::Verbatim(err.to_compile_error()),
        };
        conds.push(expr);
    }

    let desc = conds
        .last()
        .map(|expr| match expr {
            Expr::Lit(ExprLit {
                lit: Lit::Str(str), ..
            }) => Some(str.value()),
            _ => None,
        })
        .unwrap_or(None);

    if desc.is_some() {
        conds.pop();
        segments_stream.pop();
    }

    (conds, segments_stream, desc)
}
/// Parse attributes into a list of expression and an optional description of
/// the assert
Parse attributes into a list of expression and an optional description of
the assert
Parse attributes into a list of expression and an optional description of the assert
pub(crate) fn parse_attributes(
    attrs: TokenStream,
) -> (Vec<Expr>, Vec<TokenStream>, Option<String>) {
    let segments = segment_input(attrs);
    let mut segments_stream: Vec<TokenStream> = segments
        .iter()
        .map(|x| x.iter().cloned().collect::<TokenStream>())
        .collect();
    let rewritten_segs: Vec<_> = segments.into_iter().map(rewrite).collect();
    let mut conds: Vec<Expr> = vec![];
    for seg in rewritten_segs {
        let expr = match syn::parse2::<Expr>(seg) {
            Ok(val) => val,
            Err(err) => Expr::Verbatim(err.to_compile_error()),
        };
        conds.push(expr);
    }
    let desc = conds
        .last()
        .map(|expr| match expr {
            Expr::Lit(ExprLit {
                lit: Lit::Str(str), ..
            }) => Some(str.value()),
            _ => None,
        })
        .unwrap_or(None);
    if desc.is_some() {
        conds.pop();
        segments_stream.pop();
    }
    (conds, segments_stream, desc)
}
pub ( crate ) fn parse_attributes ( attrs : TokenStream , ) -> ( Vec < Expr > , Vec < TokenStream > , Option < String > ) { let segments = segment_input ( attrs ) ; let mut segments_stream : Vec < TokenStream > = segments . iter ( ) . map ( | x | x . iter ( ) . cloned ( ) . collect :: < TokenStream > ( ) ) . collect ( ) ; let rewritten_segs : Vec < _ > = segments . into_iter ( ) . map ( rewrite ) . collect ( ) ; let mut conds : Vec < Expr > = vec ! [ ] ; for seg in rewritten_segs { let expr = match syn :: parse2 :: < Expr > ( seg ) { Ok ( val ) => val , Err ( err ) => Expr :: Verbatim ( err . to_compile_error ( ) ) , } ; conds . push ( expr ) ; } let desc = conds . last ( ) . map ( | expr | match expr { Expr :: Lit ( ExprLit { lit : Lit :: Str ( str ) , .. } ) => Some ( str . value ( ) ) , _ => None , } ) . unwrap_or ( None ) ; if desc . is_some ( ) { conds . pop ( ) ; segments_stream . pop ( ) ; } ( conds , segments_stream , desc ) }
Parse attributes into a list of expression and an optional description of
the assert
Parse attributes into a list of expression and an optional description of the assert
attrs
TokenStream
attrs
TokenStream