mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-22 04:34:51 +00:00
Format code
This commit is contained in:
parent
0ff1e6c697
commit
72a3dee16f
@ -804,12 +804,12 @@ impl<T> MaybeUninit<T> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Extracts the values from an array of `MaybeUninit` containers.
|
||||
///
|
||||
/// Extracts the values from an array of `MaybeUninit` containers.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
///
|
||||
/// It is up to the caller to guarantee that all elements of the array are
|
||||
/// in an initialized state.
|
||||
/// in an initialized state.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
@ -817,17 +817,17 @@ impl<T> MaybeUninit<T> {
|
||||
/// #![feature(maybe_uninit_uninit_array)]
|
||||
/// #![feature(maybe_uninit_array_assume_init)]
|
||||
/// use std::mem::MaybeUninit;
|
||||
///
|
||||
///
|
||||
/// let mut array: [MaybeUninit<i32>; 3] = MaybeUninit::uninit_array();
|
||||
/// array[0] = MaybeUninit::new(0);
|
||||
/// array[1] = MaybeUninit::new(1);
|
||||
/// array[2] = MaybeUninit::new(2);
|
||||
///
|
||||
///
|
||||
/// // SAFETY: Now safe as we initialised all elements
|
||||
/// let array = unsafe {
|
||||
/// MaybeUninit::array_assume_init(array)
|
||||
/// };
|
||||
///
|
||||
///
|
||||
/// assert_eq!(array, [0, 1, 2]);
|
||||
/// ```
|
||||
#[unstable(feature = "maybe_uninit_array_assume_init", issue = "none")]
|
||||
@ -846,9 +846,7 @@ impl<T> MaybeUninit<T> {
|
||||
unsafe {
|
||||
intrinsics::assert_inhabited::<T>();
|
||||
|
||||
let array = ArrayInit {
|
||||
maybe_uninit: ManuallyDrop::new(array),
|
||||
};
|
||||
let array = ArrayInit { maybe_uninit: ManuallyDrop::new(array) };
|
||||
ManuallyDrop::into_inner(array.init)
|
||||
}
|
||||
}
|
||||
|
@ -149,10 +149,8 @@ fn uninit_array_assume_init() {
|
||||
array[3].write(1);
|
||||
array[4].write(5);
|
||||
|
||||
let array = unsafe {
|
||||
MaybeUninit::array_assume_init(array)
|
||||
};
|
||||
|
||||
let array = unsafe { MaybeUninit::array_assume_init(array) };
|
||||
|
||||
assert_eq!(array, [3, 1, 4, 1, 5]);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user