Skip to content

Commit ffcbeab

Browse files
authored
Rollup merge of rust-lang#148867 - edwloef:refactor-box-take, r=joboet
Refactor `Box::take` as per rust-lang#147227 (comment)
2 parents dab1ae9 + a0fe930 commit ffcbeab

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

library/alloc/src/boxed.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -725,9 +725,9 @@ impl<T, A: Allocator> Box<T, A> {
725725
#[unstable(feature = "box_take", issue = "147212")]
726726
pub fn take(boxed: Self) -> (T, Box<mem::MaybeUninit<T>, A>) {
727727
unsafe {
728-
let (raw, alloc) = Box::into_raw_with_allocator(boxed);
728+
let (raw, alloc) = Box::into_non_null_with_allocator(boxed);
729729
let value = raw.read();
730-
let uninit = Box::from_raw_in(raw.cast::<mem::MaybeUninit<T>>(), alloc);
730+
let uninit = Box::from_non_null_in(raw.cast_uninit(), alloc);
731731
(value, uninit)
732732
}
733733
}

0 commit comments

Comments
 (0)