+ }
+ }
+ _ => {},
+ }
+ }
+
+ write!(w, "<").unwrap();
+ for (idx, generic) in generics.params.iter().enumerate() {
+ match generic {
+ syn::GenericParam::Type(type_param) => {
+ write!(w, "{}", if idx != 0 { ", " } else { "" }).unwrap();
+ let type_ident = &type_param.ident;
+ types.write_c_type_in_generic_param(w, &syn::parse_quote!(#type_ident), Some(&gen_types), false);
+ },
+ syn::GenericParam::Lifetime(lt) => {
+ if concrete_lifetimes {
+ write!(w, "'static").unwrap();
+ } else {
+ write!(w, "{}'{}", if idx != 0 { ", " } else { "" }, lt.lifetime.ident).unwrap();
+ }
+ },
+ _ => unimplemented!(),
+ }
+ }
+ write!(w, ">").unwrap();
+}
+
+pub fn maybe_write_lifetime_generics<W: std::io::Write>(w: &mut W, generics: &syn::Generics, types: &TypeResolver) {
+ let mut gen_types = GenericTypes::new(None);
+ assert!(gen_types.learn_generics(generics, types));
+ if generics.params.iter().any(|param| if let syn::GenericParam::Lifetime(_) = param { true } else { false }) {
+ write!(w, "<").unwrap();
+ for (idx, generic) in generics.params.iter().enumerate() {
+ match generic {
+ syn::GenericParam::Type(_) => {},