fn collect_validation(args: &Vec<TransformedArg>) -> proc_macro2::TokenStream {
    //  Construct a new `TokenStream` to accumulate the expanded code.
    //  We use `TokenStream` instead of string because `TokenStream` remembers the source location (span) in case of errors.
    //  `quote!` returns `proc_macro2::TokenStream` instead of `proc_macro::TokenStream`, so we use `proc_macro2::TokenStream`.
    let mut expanded = proc_macro2::TokenStream::new();
    for arg in args {
        //  Construct the call validation tokens, preserving the span.
        let TransformedArg{ validation_stmt, ident_span, .. } = arg;
        if validation_stmt.as_str() == "" { continue; }
        let stmt_token = syn::parse_str::<Expr>(validation_stmt).unwrap();
        let tokens = quote_spanned!(**ident_span=> #stmt_token);
        expanded.extend(quote!{ #tokens ; });  //  Add a semicolon.
    }
    //  Return the expanded tokens.
    //  println!("expanded: {:#?}", expanded);
    expanded
}
/// Collect the Validate Statements for all args. Return a TokenStream of the validation statements for the wrapper function:
/// `Strn::validate_bytestr(name.bytestr); ...`
/// Preserve the span info for error display.
Collect the Validate Statements for all args. Return a TokenStream of the validation statements for the wrapper function:
`Strn::validate_bytestr(name.bytestr); ...`
Preserve the span info for error display.
Collect the Validate Statements for all args . Return a TokenStream of the validation statements for the wrapper function : ` Strn :: validate_bytestr ( name . bytestr ) ; ... ` Preserve the span info for error display .
fn collect_validation(args: &Vec<TransformedArg>) -> proc_macro2::TokenStream {
    //  Construct a new `TokenStream` to accumulate the expanded code.
    //  We use `TokenStream` instead of string because `TokenStream` remembers the source location (span) in case of errors.
    //  `quote!` returns `proc_macro2::TokenStream` instead of `proc_macro::TokenStream`, so we use `proc_macro2::TokenStream`.
    let mut expanded = proc_macro2::TokenStream::new();
    for arg in args {
        //  Construct the call validation tokens, preserving the span.
        let TransformedArg{ validation_stmt, ident_span, .. } = arg;
        if validation_stmt.as_str() == "" { continue; }
        let stmt_token = syn::parse_str::<Expr>(validation_stmt).unwrap();
        let tokens = quote_spanned!(**ident_span=> #stmt_token);
        expanded.extend(quote!{ #tokens ; });  //  Add a semicolon.
    }
    //  Return the expanded tokens.
    //  println!("expanded: {:#?}", expanded);
    expanded
}
fn collect_validation ( args : & Vec < TransformedArg > ) -> proc_macro2 :: TokenStream { //  Construct a new `TokenStream` to accumulate the expanded code. //  We use `TokenStream` instead of string because `TokenStream` remembers the source location (span) in case of errors. //  `quote!` returns `proc_macro2::TokenStream` instead of `proc_macro::TokenStream`, so we use `proc_macro2::TokenStream`. let mut expanded = proc_macro2 :: TokenStream :: new ( ) ; for arg in args { //  Construct the call validation tokens, preserving the span. let TransformedArg { validation_stmt , ident_span , .. } = arg ; if validation_stmt . as_str ( ) == " " { continue ; } let stmt_token = syn :: parse_str :: < Expr > ( validation_stmt ) . unwrap ( ) ; let tokens = quote_spanned ! ( ident_span stmt_token ) ; expanded . extend ( quote ! { tokens } ) ; //  Add a semicolon. } //  Return the expanded tokens. //  println!("expanded: {:#?}", expanded); expanded }
Collect the Validate Statements for all args.
Collect the Validate Statements for all args .
args
&Vec<TransformedArg>
args
&Vec<TransformedArg>