Rollup merge of #73459 - cuviper:into_boxed_slice-unicast, r=dtolnay
Reduce pointer casts in Box::into_boxed_slice We only need to cast the pointer once to change `Box<T>` to an array `Box<[T; 1]>`, then we can let unsized coercion return `Box<[T]>`.
This commit is contained in:
commit
fc2ce7cfef
@ -248,7 +248,7 @@ pub fn pin(x: T) -> Pin<Box<T>> {
|
||||
#[unstable(feature = "box_into_boxed_slice", issue = "71582")]
|
||||
pub fn into_boxed_slice(boxed: Box<T>) -> Box<[T]> {
|
||||
// *mut T and *mut [T; 1] have the same size and alignment
|
||||
unsafe { Box::from_raw(Box::into_raw(boxed) as *mut [T; 1] as *mut [T]) }
|
||||
unsafe { Box::from_raw(Box::into_raw(boxed) as *mut [T; 1]) }
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user