Skip to content

Commit 85846b4

Browse files
committed
Handle Option<Vec<_>> with a much cleaner option converter
1 parent aab29c4 commit 85846b4

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

c-bindings-gen/src/types.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1717,10 +1717,10 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
17171717
(format!("{} {{ None }} else {{ Some(", s), format!("unsafe {{ &mut *{} }}", var_access))
17181718
], ") }", ContainerPrefixLocation::NoPrefix)),
17191719
EmptyValExpectedTy::OptionType =>
1720-
return Some(("{ /* ", vec![
1721-
(format!("*/ let {}_opt = {};", var_name, var_access),
1722-
format!("}} if {}_opt{} {{ None }} else {{ Some({{ {}_opt.take()", var_name, s, var_name))
1723-
], ") } }", ContainerPrefixLocation::PerConv)),
1720+
return Some(("{ /*", vec![
1721+
(format!("*/ let {}_opt = {}; if {}_opt{} {{ None }} else {{ Some({{", var_name, var_access, var_name, s),
1722+
format!("{{ {}_opt.take() }}", var_name))
1723+
], "})} }", ContainerPrefixLocation::PerConv)),
17241724
EmptyValExpectedTy::NonPointer =>
17251725
return Some(("if ", vec![
17261726
(format!("{} {{ None }} else {{ Some(", s), format!("{}", var_access))

0 commit comments

Comments
 (0)