// Create a binding for an argument given. If it requires an index, take from the index
Create a binding for an argument given. If it requires an index, take from the index
Create a binding for an argument given . If it requires an index take from the index
fn render_binding_arg(arg: &StarArg) -> TokenStream {
    let name = &arg.name;
    let name_str = ident_string(name);
    let ty = &arg.ty;
    let source = match arg.source {
        StarArgSource::This => quote! {__this},
        StarArgSource::Argument(i) => quote! {__args[#i].get()},
        StarArgSource::Required(i) => quote! {Some(__required[#i])},
        StarArgSource::Optional(i) => quote! {__optional[#i]},
        _ => unreachable!(),
    };
    // Rust doesn't have powerful enough nested if yet
    let next = if arg.is_this() {
        quote! { starlark::eval::Arguments::check_this(#source)? }
    } else if arg.is_option() {
        assert!(
            arg.default.is_none(),
            "Can't have Option argument with a default, for `{}`",
            name_str
        );
        quote! { starlark::eval::Arguments::check_optional(#name_str, #source)? }
    } else if !arg.is_value() && arg.default.is_some() {
        let default = arg
            .default
            .as_ref()
            .unwrap_or_else(|| unreachable!("Checked on the line above"));
        quote! { starlark::eval::Arguments::check_optional(#name_str, #source)?.unwrap_or(#default) }
    } else {
        quote! { starlark::eval::Arguments::check_required(#name_str, #source)? }
    };
    let mutability = mut_token(arg.mutable);
    let attrs = &arg.attrs;
    quote! {
        #( #attrs )*
        let #mutability #name: #ty = #next;
    }
}
fn render_binding_arg ( arg : & StarArg ) -> TokenStream { let name = & arg . name ; let name_str = ident_string ( name ) ; let ty = & arg . ty ; let source = match arg . source { StarArgSource :: This => quote ! { __this } , StarArgSource :: Argument ( i ) => quote ! { __args [ i ] get ( ) } , StarArgSource :: Required ( i ) => quote ! { Some ( __required [ i ] ) } , StarArgSource :: Optional ( i ) => quote ! { __optional [ i ] } , _ => unreachable ! ( ) , } ; // Rust doesn't have powerful enough nested if yet let next = if arg . is_this ( ) { quote ! { starlark eval Arguments check_this ( source ) } } else if arg . is_option ( ) { assert ! ( arg default is_none ( ) " " name_str ) ; quote ! { starlark eval Arguments check_optional ( name_str source ) } } else if ! arg . is_value ( ) && arg . default . is_some ( ) { let default = arg . default . as_ref ( ) . unwrap_or_else ( | | unreachable ! ( " " ) ) ; quote ! { starlark eval Arguments check_optional ( name_str source ) unwrap_or ( default ) } } else { quote ! { starlark eval Arguments check_required ( name_str source ) } } ; let mutability = mut_token ( arg . mutable ) ; let attrs = & arg . attrs ; quote ! { ( attrs ) let mutability name ty next } }
Create a binding for an argument given.
Create a binding for an argument given .
arg
&StarArg