From b4335d28d94291e1d91a3f2c86887d2b75dd1681 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Thu, 29 Feb 2024 14:56:22 +0000 Subject: [PATCH] Handle `-> ()` as an fn return value --- c-bindings-gen/src/blocks.rs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/c-bindings-gen/src/blocks.rs b/c-bindings-gen/src/blocks.rs index 7ee216a..eb3d56e 100644 --- a/c-bindings-gen/src/blocks.rs +++ b/c-bindings-gen/src/blocks.rs @@ -593,14 +593,19 @@ pub fn write_method_params(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); }, _ => {}, } -- 2.39.5