Format code

This commit is contained in:
CoffeeBlend 2021-01-01 22:56:54 +01:00
parent 0ff1e6c697
commit 72a3dee16f
No known key found for this signature in database
GPG Key ID: 704E0149B0194B3C
2 changed files with 10 additions and 14 deletions

View File

@ -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)
}
}

View File

@ -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]);
}