Skip to content

Commit e1dd5fa

Browse files
committed
Ensure an option always unwraps to a non-reference type
1 parent 85846b4 commit e1dd5fa

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

c-bindings-gen/src/types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1624,7 +1624,7 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
16241624
let inner_name = self.get_c_mangled_container_type(vec![single_contained.unwrap()], generics, "Option").unwrap();
16251625
return Some(("if ", vec![
16261626
(format!(".is_none() {{ {}::None }} else {{ {}::Some(/* WARNING: CLONING CONVERSION HERE! &Option<Enum> is otherwise un-expressable. */", inner_name, inner_name),
1627-
format!("{}.clone().unwrap()", var_access))
1627+
format!("(*{}.as_ref().unwrap()).clone()", var_access))
16281628
], ") }", ContainerPrefixLocation::PerConv));
16291629
}
16301630
} else {

0 commit comments

Comments
 (0)