Support traits and structs with lifetime bounds (which are ignored)
[ldk-c-bindings] / c-bindings-gen / src / main.rs
index 4d5b07021c7cd110aafe6917fa77a2f5dd70880a..280f94e9de408af0e367d67234cec85f672a939b 100644 (file)
@@ -491,13 +491,18 @@ fn writeln_trait<'a, 'b, W: std::io::Write>(w: &mut W, t: &'a syn::ItemTrait, ty
                                        &syn::TraitItem::Type(ref t) => {
                                                if t.default.is_some() || t.generics.lt_token.is_some() { unimplemented!(); }
                                                let mut bounds_iter = t.bounds.iter();
-                                               match bounds_iter.next().unwrap() {
-                                                       syn::TypeParamBound::Trait(tr) => {
-                                                               writeln!(w, "\ttype {} = crate::{};", t.ident, $type_resolver.resolve_path(&tr.path, Some(&gen_types))).unwrap();
-                                                       },
-                                                       _ => unimplemented!(),
+                                               loop {
+                                                       match bounds_iter.next().unwrap() {
+                                                               syn::TypeParamBound::Trait(tr) => {
+                                                                       writeln!(w, "\ttype {} = crate::{};", t.ident, $type_resolver.resolve_path(&tr.path, Some(&gen_types))).unwrap();
+                                                                       for bound in bounds_iter {
+                                                                               if let syn::TypeParamBound::Trait(_) = bound { unimplemented!(); }
+                                                                       }
+                                                                       break;
+                                                               },
+                                                               syn::TypeParamBound::Lifetime(_) => {},
+                                                       }
                                                }
-                                               if bounds_iter.next().is_some() { unimplemented!(); }
                                        },
                                        _ => unimplemented!(),
                                }