From e1dd5fa811b8fecf0e0abdd6c7280a94489cc7b9 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Tue, 25 Apr 2023 22:13:38 +0000 Subject: [PATCH] Ensure an option always unwraps to a non-reference type --- c-bindings-gen/src/types.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/c-bindings-gen/src/types.rs b/c-bindings-gen/src/types.rs index 8cc7d1e..f47bf9e 100644 --- a/c-bindings-gen/src/types.rs +++ b/c-bindings-gen/src/types.rs @@ -1624,7 +1624,7 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> { let inner_name = self.get_c_mangled_container_type(vec![single_contained.unwrap()], generics, "Option").unwrap(); return Some(("if ", vec![ (format!(".is_none() {{ {}::None }} else {{ {}::Some(/* WARNING: CLONING CONVERSION HERE! &Option is otherwise un-expressable. */", inner_name, inner_name), - format!("{}.clone().unwrap()", var_access)) + format!("(*{}.as_ref().unwrap()).clone()", var_access)) ], ") }", ContainerPrefixLocation::PerConv)); } } else { -- 2.39.5