writeln!(w, "\t#[allow(unused)] pub(crate) fn is_some(&self) -> bool {{").unwrap();
writeln!(w, "\t\tif let Self::Some(_) = self {{ true }} else {{ false }}").unwrap();
writeln!(w, "\t}}").unwrap();
+ writeln!(w, "\t#[allow(unused)] pub(crate) fn is_none(&self) -> bool {{").unwrap();
+ writeln!(w, "\t\t!self.is_some()").unwrap();
+ writeln!(w, "\t}}").unwrap();
writeln!(w, "\t#[allow(unused)] pub(crate) fn take(mut self) -> {} {{", inner_type).unwrap();
writeln!(w, "\t\tif let Self::Some(v) = self {{ v }} else {{ unreachable!() }}").unwrap();
writeln!(w, "\t}}").unwrap();
write!(w, "ret").unwrap();
} else if !to_c && self_segs_iter.is_some() && self_segs_iter.unwrap().next().is_none() {
// If we're returning "Self" (and not "Self::X"), just do it manually
- write!(w, "{} {{ inner: Box::into_raw(Box::new(ret)), is_owned: true }}", this_type).unwrap();
+ write!(w, "{} {{ inner: ObjOps::heap_alloc(ret), is_owned: true }}", this_type).unwrap();
} else if to_c {
let new_var = types.write_from_c_conversion_new_var(w, &format_ident!("ret"), rtype, generics);
if new_var {