From: Matt Corallo Date: Tue, 25 Apr 2023 20:21:03 +0000 (+0000) Subject: Handle Option> with a much cleaner option converter X-Git-Tag: v0.0.115.0^2~4 X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=85846b4b2d0e7378ce2d4605f6356925f89e736b;p=ldk-c-bindings Handle Option> with a much cleaner option converter --- diff --git a/c-bindings-gen/src/types.rs b/c-bindings-gen/src/types.rs index b92ca77..8cc7d1e 100644 --- a/c-bindings-gen/src/types.rs +++ b/c-bindings-gen/src/types.rs @@ -1717,10 +1717,10 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> { (format!("{} {{ None }} else {{ Some(", s), format!("unsafe {{ &mut *{} }}", var_access)) ], ") }", ContainerPrefixLocation::NoPrefix)), EmptyValExpectedTy::OptionType => - return Some(("{ /* ", vec![ - (format!("*/ let {}_opt = {};", var_name, var_access), - format!("}} if {}_opt{} {{ None }} else {{ Some({{ {}_opt.take()", var_name, s, var_name)) - ], ") } }", ContainerPrefixLocation::PerConv)), + return Some(("{ /*", vec![ + (format!("*/ let {}_opt = {}; if {}_opt{} {{ None }} else {{ Some({{", var_name, var_access, var_name, s), + format!("{{ {}_opt.take() }}", var_name)) + ], "})} }", ContainerPrefixLocation::PerConv)), EmptyValExpectedTy::NonPointer => return Some(("if ", vec![ (format!("{} {{ None }} else {{ Some(", s), format!("{}", var_access))