[−][src]Trait ptrplus::IntoRaw
Trait for types that implement into_raw
This is implemented by types that can be converted into a pointer by consuming ownership of the object
Example
use ptrplus::IntoRaw; let x: Box<u32> = Box::new(5); let y: *mut u32 = IntoRaw::into_raw(x); unsafe { assert_eq!(*y, 5); *y = 6; Box::from_raw(y); }
use ptrplus::{FromRaw, IntoRaw}; let o1: Option<Box<u32>> = None; let o2: Option<Box<u32>> = Some(Box::new(5)); let p1: *mut u32 = o1.into_raw(); let p2: *mut u32 = o2.into_raw(); assert!(p1.is_null()); assert!(!p2.is_null()); unsafe { assert_eq!(*p2, 5); let o1: Option<Box<u32>> = Option::from_raw(p1); let o2: Option<Box<u32>> = Option::from_raw(p2); assert!(o1.is_none()); assert!(!o2.is_none()); }
Associated Types
Loading content...Required methods
pub fn into_raw(self) -> *mut Self::Raw
[src]
Consumes self
returning the wrapped raw pointer.
After calling this method, the caller is responsable
for making sure any resources attached to this pointer
(such as memory) are cleaned up. The proper way to do this
is to convert the pointer back to Self
.
See FromRaw
Implementations on Foreign Types
impl IntoRaw for CString
[src]
impl<T> IntoRaw for *mut T
[src]
impl<T> IntoRaw for NonNull<T>
[src]
impl<T> IntoRaw for Option<T> where
T: IntoRaw,
[src]
T: IntoRaw,