Support building dependent crates with `no-std`
[ldk-c-bindings] / c-bindings-gen / src / main.rs
index 4d5b07021c7cd110aafe6917fa77a2f5dd70880a..f6e60cb5e67105e5e7c3e358911e6904ae463d10 100644 (file)
@@ -175,7 +175,7 @@ fn do_write_impl_trait<W: std::io::Write>(w: &mut W, trait_path: &str, _trait_na
        match trait_path {
                "lightning::util::ser::Writeable" => {
                        writeln!(w, "impl {} for {} {{", trait_path, for_obj).unwrap();
-                       writeln!(w, "\tfn write<W: lightning::util::ser::Writer>(&self, w: &mut W) -> Result<(), ::std::io::Error> {{").unwrap();
+                       writeln!(w, "\tfn write<W: lightning::util::ser::Writer>(&self, w: &mut W) -> Result<(), crate::c_types::io::Error> {{").unwrap();
                        writeln!(w, "\t\tlet vec = (self.write)(self.this_arg);").unwrap();
                        writeln!(w, "\t\tw.write_all(vec.as_slice())").unwrap();
                        writeln!(w, "\t}}\n}}").unwrap();
@@ -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!(),
                                }