pub trait IntoNative<U> {
// Required method
unsafe fn into_native(self) -> U;
}Expand description
Convert a C datum into a native Rust object, taking ownership of
the C datum. You should not need to implement this trait
as long as Rust types implement FromForeign.
Required Methods§
Sourceunsafe fn into_native(self) -> U
unsafe fn into_native(self) -> U
Convert a C datum to a native Rust object, taking ownership of
the pointer or Rust object (same as from_glib_full in glib-rs)
§Safety
self must point to valid data, or can be NULL if U is an
Option type. It becomes invalid after the function returns.
let s = "Hello, world!".to_string();
let foreign = s.clone_to_foreign();
let native: String = unsafe {
foreign.into_native()
// foreign is not leaked
};
assert_eq!(s, native);