Repository: napi-rs/napi-rs
File: crates/backend/src/codegen/fn.rs (Rust)

Code before:
          },
        ))
      }
      _ => {
        hidden_ty_lifetime(&mut ty)?;
        let mut arg_type = NapiArgType::Value;
        if let syn::Type::Path(path) = &ty {
          // find `Vec<&S>` cases
          // in `async fn foo(v: Vec<&S>) {}` case, need to `make_ref` for `v` as well
          if let Some(syn::PathSegment { ident, arguments }) = path.path.segments.first() {
            if ident == "Vec" {
              if let syn::PathArguments::AngleBracketed(syn::AngleBracketedGenericArguments {
                args: angle_bracketed_args,
                ..
              }) = &arguments
              {
                // Vec with reference type
                if let Some(syn::GenericArgument::Type(syn::Type::Reference(
                  syn::TypeReference { .. },
                ))) = angle_bracketed_args.first()
                {
                  arg_type = NapiArgType::Ref;
                }
              }
            }
          }
        }
        let q = quote! {
          let #arg_name = {
            #type_check
            <#ty as napi::bindgen_prelude::FromNapiValue>::from_napi_value(env, cb.get_arg(#index))?
          };
        };
        Ok((q, arg_type))
      }
    }
  }

  fn gen_cb_arg_conversion(
    &self,
    arg_name: &Ident,
    index: usize,
    cb: &CallbackArg,
  ) -> BindgenResult<TokenStream> {
    let mut inputs = vec![];
    let mut arg_conversions = vec![];

    for (i, ty) in cb.args.iter().enumerate() {
      let cb_arg_ident = Ident::new(&format!("callback_arg_{}", i), Span::call_site());
      inputs.push(quote! { #cb_arg_ident: #ty });
      let mut maybe_has_lifetime_ty = ty.clone();

Review comment (suggestion):
[nitpick] The new logic for detecting Vec<&S> cases is clear; consider adding inline documentation or tests to further support future maintainability if similar generic patterns evolve.
```suggestion
          // Detect cases where the type is `Vec<&S>`.
          // For example, in `async fn foo(v: Vec<&S>) {}`, we need to handle `v` as a reference.
          if let Some(syn::PathSegment { ident, arguments }) = path.path.segments.first() {
            // Check if the type is a `Vec`.
            if ident == "Vec" {
              if let syn::PathArguments::AngleBracketed(syn::AngleBracketedGenericArguments {
                args: angle_bracketed_args,
                ..
              }) = &arguments
              {
                // Check if the generic argument of `Vec` is a reference type (e.g., `&S`).
                if let Some(syn::GenericArgument::Type(syn::Type::Reference(
                  syn::TypeReference { .. },
                ))) = angle_bracketed_args.first()
                {
                  // If the type is `Vec<&S>`, set the argument type to `Ref`.
                  arg_type = NapiArgType::Ref;
                }
              }
```

Code after:
          },
        ))
      }
      _ => {
        hidden_ty_lifetime(&mut ty)?;
        let mut arg_type = NapiArgType::Value;
        if let syn::Type::Path(path) = &ty {
          // Detect cases where the type is `Vec<&S>`.
          // For example, in `async fn foo(v: Vec<&S>) {}`, we need to handle `v` as a reference.
          if let Some(syn::PathSegment { ident, arguments }) = path.path.segments.first() {
            // Check if the type is a `Vec`.
            if ident == "Vec" {
              if let syn::PathArguments::AngleBracketed(syn::AngleBracketedGenericArguments {
                args: angle_bracketed_args,
                ..
              }) = &arguments
              {
                // Check if the generic argument of `Vec` is a reference type (e.g., `&S`).
                if let Some(syn::GenericArgument::Type(syn::Type::Reference(
                  syn::TypeReference { .. },
                ))) = angle_bracketed_args.first()
                {
                  // If the type is `Vec<&S>`, set the argument type to `Ref`.
                  arg_type = NapiArgType::Ref;
                }
              }
            }
          }
        }
        let q = quote! {
          let #arg_name = {
            #type_check
            <#ty as napi::bindgen_prelude::FromNapiValue>::from_napi_value(env, cb.get_arg(#index))?
          };
        };
        Ok((q, arg_type))
      }
    }
  }

  fn gen_cb_arg_conversion(
    &self,
    arg_name: &Ident,
    index: usize,
    cb: &CallbackArg,
  ) -> BindgenResult<TokenStream> {
    let mut inputs = vec![];
    let mut arg_conversions = vec![];

    for (i, ty) in cb.args.iter().enumerate() {
      let cb_arg_ident = Ident::new(&format!("callback_arg_{}", i), Span::call_site());