Correctly define the `native` type alias for enums with generic params
[ldk-c-bindings] / c-bindings-gen / src / main.rs
index 279424e1fde81e07ed9de1d64138ee7a3cbb5764..b21c8d8c667c51fe765c57fb622f9182d9a96701 100644 (file)
@@ -1661,7 +1661,10 @@ fn writeln_enum<'a, 'b, W: std::io::Write>(w: &mut W, e: &'a syn::ItemEnum, type
                writeln!(&mut constr, "}}").unwrap();
                writeln!(w, ",").unwrap();
        }
-       writeln!(w, "}}\nuse {}::{} as native{};\nimpl {} {{", types.module_path, e.ident, e.ident, e.ident).unwrap();
+       writeln!(w, "}}\nuse {}::{} as {}Import;", types.module_path, e.ident, e.ident).unwrap();
+       write!(w, "pub(crate) type native{} = {}Import", e.ident, e.ident).unwrap();
+       maybe_write_generics(w, &e.generics, &types, true);
+       writeln!(w, ";\n\nimpl {} {{", e.ident).unwrap();
 
        macro_rules! write_conv {
                ($fn_sig: expr, $to_c: expr, $ref: expr) => {