mirror of
https://github.com/FranLMSP/rultra64.git
synced 2026-01-01 07:51:34 -05:00
Refactor (?)
This commit is contained in:
@@ -1,15 +1,11 @@
|
||||
#[macro_export]
|
||||
macro_rules! box_array {
|
||||
($val:expr ; $len:expr) => {{
|
||||
// Use a generic function so that the pointer cast remains type-safe
|
||||
fn vec_to_boxed_array<T>(vec: Vec<T>) -> Box<[T; $len]> {
|
||||
let boxed_slice = vec.into_boxed_slice();
|
||||
|
||||
let ptr = ::std::boxed::Box::into_raw(boxed_slice) as *mut [T; $len];
|
||||
|
||||
unsafe { Box::from_raw(ptr) }
|
||||
}
|
||||
|
||||
vec_to_boxed_array(vec![$val; $len])
|
||||
}};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user