writeln!(w, "\t}}").unwrap();
writeln!(w, "}}").unwrap();
- // TODO: Templates should use () now that they can, too
- let templ_ok_type = if ok_type != "()" { ok_type } else { "u8" };
- let templ_err_type = if err_type != "()" { err_type } else { "u8" };
-
- writeln!(w, "impl From<crate::c_types::CResultTempl<{}, {}>> for {} {{", templ_ok_type, templ_err_type, mangled_container).unwrap();
- writeln!(w, "\tfn from(mut o: crate::c_types::CResultTempl<{}, {}>) -> Self {{", templ_ok_type, templ_err_type).unwrap();
+ writeln!(w, "impl From<crate::c_types::CResultTempl<{}, {}>> for {} {{", ok_type, err_type, mangled_container).unwrap();
+ writeln!(w, "\tfn from(mut o: crate::c_types::CResultTempl<{}, {}>) -> Self {{", ok_type, err_type).unwrap();
writeln!(w, "\t\tlet contents = if o.result_ok {{").unwrap();
if ok_type != "()" {
writeln!(w, "\t\t\tlet result = unsafe {{ o.contents.result }};").unwrap();
write!(w, "{}r", if new_var { "local_" } else { "" }).unwrap();
types.write_to_c_conversion_inline_suffix(w, &*i.self_ty, Some(&gen_types), false);
writeln!(w, "\n\t\t\t)\n\t\t}},").unwrap();
- writeln!(w, "\t\tErr(e) => crate::c_types::CResultTempl::err(0u8),").unwrap();
+ writeln!(w, "\t\tErr(e) => crate::c_types::CResultTempl::err(()),").unwrap();
writeln!(w, "\t}}.into()\n}}").unwrap();
}
} else if path_matches_nongeneric(&trait_path.1, &["Display"]) {
}
fn write_to_c_conversion_inline_prefix_inner<W: std::io::Write>(&self, w: &mut W, t: &syn::Type, generics: Option<&GenericTypes>, is_ref: bool, ptr_for_ref: bool, from_ptr: bool) {
- self.write_conversion_inline_intern(w, t, generics, is_ref, false, ptr_for_ref, "0u8 /*", true, |_, _| "local_".to_owned(),
+ self.write_conversion_inline_intern(w, t, generics, is_ref, false, ptr_for_ref, "() /*", true, |_, _| "local_".to_owned(),
|a, b, c| self.to_c_conversion_inline_prefix_from_path(a, b, c),
|w, decl_type, decl_path, is_ref, _is_mut| {
match decl_type {