Function std::boxed::into_raw
[−]
[src]
pub fn into_raw<T>(b: Box<T>) -> *mut T where T: ?Sized
: may be renamed
Consumes the Box
, returning the wrapped raw pointer.
After call to this function, caller is responsible for the memory
previously managed by Box
, in particular caller should properly
destroy T
and release memory. The proper way to do it is to
convert pointer back to Box
with Box::from_raw
function, because
Box
does not specify, how memory is allocated.
Examples
#![feature(alloc)] fn main() { use std::boxed; let seventeen = Box::new(17u32); let raw = boxed::into_raw(seventeen); let boxed_again = unsafe { Box::from_raw(raw) }; }use std::boxed; let seventeen = Box::new(17u32); let raw = boxed::into_raw(seventeen); let boxed_again = unsafe { Box::from_raw(raw) };