Function alloc::boxed::into_raw [] [src]

pub unsafe fn into_raw<T: ?Sized>(b: Box<T>) -> *mut T
Unstable

: may be renamed

Consumes the Box`Box`, returning the wrapped raw pointer.

After call to this function, caller is responsible for the memory previously managed by Box`Box, in particular caller should properly destroy`, in particular caller should properly destroy T`Tand release memory. The proper way to do it is to convert pointer back to` and release memory. The proper way to do it is to convert pointer back to Box`Boxwith` with Box::from_raw`Box::from_rawfunction, because` function, because Box`Box` does not specify, how memory is allocated.

Function is unsafe, because result of this function is no longer automatically managed that may lead to memory or other resource leak.

Examples

use std::boxed;

let seventeen = Box::new(17u32);
let raw = unsafe { boxed::into_raw(seventeen) };
let boxed_again = unsafe { Box::from_raw(raw) };