fn impl_arg_param(
    arg: &FnArg<'_>,
    spec: &FnSpec<'_>,
    idx: usize,
    option_pos: &mut usize,
) -> TokenStream {
    let arg_name = syn::Ident::new(&format!("arg{}", idx), Span::call_site());

    if arg.py {
        return quote! {
            let #arg_name = _py;
        };
    }
    let arg_value = quote!(output[#option_pos]);
    *option_pos += 1;

    let ty = arg.ty;
    let name = arg.name;

    if spec.is_args(&name) {
        quote! {
            let #arg_name = <#ty as pyo3::FromPyObject>::extract(_args.as_ref())?;
        }
    } else if spec.is_kwargs(&name) {
        quote! {
            let #arg_name = _kwargs;
        }
    } else if arg.optional.is_some() {
        let default = if let Some(d) = spec.default_value(name) {
            quote! { Some(#d) }
        } else {
            quote! { None }
        };

        quote! {
            let #arg_name = match #arg_value.as_ref() {
                Some(_obj) => {
                    if _obj.is_none() {
                        #default
                    } else {
                        Some(_obj.extract()?)
                    }
                },
                None => #default
            };
        }
    } else if let Some(default) = spec.default_value(name) {
        quote! {
            let #arg_name = match #arg_value.as_ref() {
                Some(_obj) => {
                    if _obj.is_none() {
                        #default
                    } else {
                        _obj.extract()?
                    }
                },
                None => #default
            };
        }
    } else {
        quote! {
            let #arg_name = #arg_value.unwrap().extract()?;
        }
    }
}
/// Re option_pos: The option slice doesn't contain the py: Python argument, so the argument
/// index and the index in option diverge when using py: Python
Re option_pos: The option slice doesn't contain the py: Python argument, so the argument
index and the index in option diverge when using py: Python
Re option_pos : The option slice doesn ' t contain the py : Python argument so the argument index and the index in option diverge when using py : Python
fn impl_arg_param(
    arg: &FnArg<'_>,
    spec: &FnSpec<'_>,
    idx: usize,
    option_pos: &mut usize,
) -> TokenStream {
    let arg_name = syn::Ident::new(&format!("arg{}", idx), Span::call_site());
    if arg.py {
        return quote! {
            let #arg_name = _py;
        };
    }
    let arg_value = quote!(output[#option_pos]);
    *option_pos += 1;
    let ty = arg.ty;
    let name = arg.name;
    if spec.is_args(&name) {
        quote! {
            let #arg_name = <#ty as pyo3::FromPyObject>::extract(_args.as_ref())?;
        }
    } else if spec.is_kwargs(&name) {
        quote! {
            let #arg_name = _kwargs;
        }
    } else if arg.optional.is_some() {
        let default = if let Some(d) = spec.default_value(name) {
            quote! { Some(#d) }
        } else {
            quote! { None }
        };
        quote! {
            let #arg_name = match #arg_value.as_ref() {
                Some(_obj) => {
                    if _obj.is_none() {
                        #default
                    } else {
                        Some(_obj.extract()?)
                    }
                },
                None => #default
            };
        }
    } else if let Some(default) = spec.default_value(name) {
        quote! {
            let #arg_name = match #arg_value.as_ref() {
                Some(_obj) => {
                    if _obj.is_none() {
                        #default
                    } else {
                        _obj.extract()?
                    }
                },
                None => #default
            };
        }
    } else {
        quote! {
            let #arg_name = #arg_value.unwrap().extract()?;
        }
    }
}
fn impl_arg_param ( arg : & FnArg < ' _ > , spec : & FnSpec < ' _ > , idx : usize , option_pos : & mut usize , ) -> TokenStream { let arg_name = syn :: Ident :: new ( & format ! ( " " idx ) , Span :: call_site ( ) ) ; if arg . py { return quote ! { let arg_name _py } ; } let arg_value = quote ! ( output [ option_pos ] ) ; * option_pos += 1 ; let ty = arg . ty ; let name = arg . name ; if spec . is_args ( & name ) { quote ! { let arg_name ty as pyo3 FromPyObject extract ( _args as_ref ( ) ) } } else if spec . is_kwargs ( & name ) { quote ! { let arg_name _kwargs } } else if arg . optional . is_some ( ) { let default = if let Some ( d ) = spec . default_value ( name ) { quote ! { Some ( d ) } } else { quote ! { None } } ; quote ! { let arg_name match arg_value as_ref ( ) { Some ( _obj ) { if _obj is_none ( ) { default } else { Some ( _obj extract ( ) ) } } None default } } } else if let Some ( default ) = spec . default_value ( name ) { quote ! { let arg_name match arg_value as_ref ( ) { Some ( _obj ) { if _obj is_none ( ) { default } else { _obj extract ( ) } } None default } } } else { quote ! { let arg_name arg_value unwrap ( ) extract ( ) } } }
Re option_pos: The option slice doesn't contain the py: Python argument, so the argument
index and the index in option diverge when using py: Python
Re option_pos : The option slice doesn ' t contain the py : Python argument so the argument index and the index in option diverge when using py : Python
arg
&FnArg<'_>
spec
&FnSpec<'_>
idx
usize
option_pos
&mut usize
arg
&FnArg<'_>
spec
&FnSpec<'_>
idx
usize
option_pos
&mut usize