]> git.bitcoin.ninja Git - ldk-c-bindings/commitdiff
impl `Display` properly even if its written as `core::fmt::Display`
authorMatt Corallo <git@bluematt.me>
Tue, 4 Jun 2024 15:51:25 +0000 (15:51 +0000)
committerMatt Corallo <git@bluematt.me>
Tue, 4 Jun 2024 15:51:25 +0000 (15:51 +0000)
c-bindings-gen/src/main.rs

index fd4ea8f4f95705f8e14f4668e4284052d2de69c7..12d0772fbb496fab0c8522f04119a8c7a19bd408 100644 (file)
@@ -1408,7 +1408,9 @@ fn writeln_impl<W: std::io::Write>(w: &mut W, w_uses: &mut HashSet<String, NonRa
 
                                                write!(w, "\talloc::format!(\"{{:?}}\", unsafe {{ o as *const crate::{} }}).into()", resolved_path).unwrap();
                                                writeln!(w, "}}").unwrap();
-                                       } else if path_matches_nongeneric(&trait_path.1, &["Display"]) {
+                                       } else if full_trait_path_opt.as_ref().map(|s| s.as_str()) == Some("core::fmt::Display") ||
+                                               path_matches_nongeneric(&trait_path.1, &["Display"])
+                                       {
                                                writeln!(w, "#[no_mangle]").unwrap();
                                                writeln!(w, "/// Get the string representation of a {} object", ident).unwrap();
                                                writeln!(w, "pub extern \"C\" fn {}_to_str(o: &crate::{}) -> Str {{", ident, resolved_path).unwrap();