]> git.bitcoin.ninja Git - ldk-c-bindings/commitdiff
Handle `-> ()` as an fn return value
authorMatt Corallo <git@bluematt.me>
Thu, 29 Feb 2024 14:56:22 +0000 (14:56 +0000)
committerMatt Corallo <git@bluematt.me>
Thu, 25 Apr 2024 20:52:49 +0000 (20:52 +0000)
c-bindings-gen/src/blocks.rs

index 7ee216a6774a2498c46814333760233cf796fc85..eb3d56eac2f1810d0aac61172a504a0828b235cc 100644 (file)
@@ -593,14 +593,19 @@ pub fn write_method_params<W: std::io::Write>(w: &mut W, sig: &syn::Signature, t
        write!(w, ")").unwrap();
        match &sig.output {
                syn::ReturnType::Type(_, rtype) => {
-                       write!(w, " -> ").unwrap();
-                       if let Some(mut remaining_path) = first_seg_self(&*rtype) {
-                               if remaining_path.next().is_none() {
-                                       write!(w, "{}", this_param).unwrap();
-                                       return;
+                       let mut ret_ty = Vec::new();
+                       types.write_c_type(&mut ret_ty, &*rtype, generics, true);
+
+                       if !ret_ty.is_empty() {
+                               write!(w, " -> ").unwrap();
+                               if let Some(mut remaining_path) = first_seg_self(&*rtype) {
+                                       if remaining_path.next().is_none() {
+                                               write!(w, "{}", this_param).unwrap();
+                                               return;
+                                       }
                                }
+                               w.write_all(&ret_ty).unwrap();
                        }
-                       types.write_c_type(w, &*rtype, generics, true);
                },
                _ => {},
        }