fn push_str_stmts()

in api_generator/src/generator/code_gen/url/url_builder.rs [404:427]


    fn push_str_stmts(url_ident: syn::Ident, url: &[PathPart<'a>]) -> Vec<syn::Stmt> {
        url.iter()
            .map(|p| match *p {
                PathPart::Literal(p) => {
                    let push = if p.len() == 1 {
                        let lit = syn::Lit::Char(p.chars().next().unwrap());
                        quote!(#url_ident.push(#lit))
                    } else {
                        let lit = syn::Lit::Str(p.to_string(), syn::StrStyle::Cooked);
                        quote!(#url_ident.push_str(#lit))
                    };

                    syn::Stmt::Semi(Box::new(parse_expr(push)))
                }
                PathPart::Param(p) => {
                    let name = format!("encoded_{}", valid_name(p));
                    let ident = ident(name);
                    syn::Stmt::Semi(Box::new(parse_expr(
                        quote!(#url_ident.push_str(#ident.as_ref())),
                    )))
                }
            })
            .collect()
    }