Correctly convert Option<Generic<Inner>> to C
[ldk-c-bindings] / c-bindings-gen / src / types.rs
index 8063532e454b169d89dbb0be8b6c2e0283fd8d1c..f87e2a075e99932d6865be53347fe04fd1a3f628 100644 (file)
@@ -867,10 +867,6 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
                        return Some(full_path);
                }
                match full_path {
-                       "Result" => Some("crate::c_types::derived::CResult"),
-                       "Vec" if !is_ref => Some("crate::c_types::derived::CVec"),
-                       "Option" => Some(""),
-
                        // Note that no !is_ref types can map to an array because Rust and C's call semantics
                        // for arrays are different (https://github.com/eqrion/cbindgen/issues/528)
 
@@ -1378,10 +1374,10 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
                                                                ], " }", ContainerPrefixLocation::OutsideConv));
                                                }
                                        } else if self.is_primitive(&inner_path) || self.c_type_from_path(&inner_path, false, false).is_none() {
-                                               let inner_name = inner_path.rsplit("::").next().unwrap();
+                                               let inner_name = self.get_c_mangled_container_type(vec![single_contained.unwrap()], generics, "Option").unwrap();
                                                return Some(("if ", vec![
-                                                       (format!(".is_none() {{ {}::COption_{}Z::None }} else {{ {}::COption_{}Z::Some(",
-                                                               Self::generated_container_path(), inner_name, Self::generated_container_path(), inner_name),
+                                                       (format!(".is_none() {{ {}::None }} else {{ {}::Some(",
+                                                               inner_name, inner_name),
                                                         format!("{}.unwrap()", var_access))
                                                        ], ") }", ContainerPrefixLocation::PerConv));
                                        } else {