I\'m trying to construct a pair of elements:
array: *mut T
array_len: usize
array
is intended to
You could use [T]::as_mut_ptr to obtain the *mut T
pointer directly from Vec
, Box<[T]>
or any other DerefMut-to-slice types.
use std::mem;
let mut boxed_slice: Box<[T]> = vector.into_boxed_slice();
let array: *mut T = boxed_slice.as_mut_ptr();
let array_len: usize = boxed_slice.len();
// Prevent the slice from being destroyed (Leak the memory).
mem::forget(boxed_slice);