diff options
| author | Ralf Jung <post@ralfj.de> | 2018-12-22 11:02:06 +0100 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2019-01-28 10:48:38 +0100 |
| commit | 22a947f3aa4b990efa135e3593fe7365bc7c36b9 (patch) | |
| tree | 59e3051f236646814c60d51f5bcc0940f2b3e9a3 /src/libcore/fmt | |
| parent | 630aaa4e801393c55c8327f642aec2349adfaee3 (diff) | |
add macro for creating uninitialized array
Diffstat (limited to 'src/libcore/fmt')
| -rw-r--r-- | src/libcore/fmt/num.rs | 14 |
1 files changed, 2 insertions, 12 deletions
diff --git a/src/libcore/fmt/num.rs b/src/libcore/fmt/num.rs index ff284d2978e..5283c6d7ef3 100644 --- a/src/libcore/fmt/num.rs +++ b/src/libcore/fmt/num.rs @@ -51,12 +51,7 @@ trait GenericRadix { // characters for a base 2 number. let zero = T::zero(); let is_nonnegative = x >= zero; - // Creating a `[MaybeUninit; N]` array by first creating a - // `MaybeUninit<[MaybeUninit; N]>`; the `into_inner` is safe because the inner - // array does not require initialization. - let mut buf: [MaybeUninit<u8>; 128] = unsafe { - MaybeUninit::uninitialized().into_inner() - }; + let mut buf = uninitialized_array![u8; 128]; let mut curr = buf.len(); let base = T::from_u8(Self::BASE); if is_nonnegative { @@ -203,12 +198,7 @@ macro_rules! impl_Display { // convert the negative num to positive by summing 1 to it's 2 complement (!self.$conv_fn()).wrapping_add(1) }; - // Creating a `[MaybeUninit; N]` array by first creating a - // `MaybeUninit<[MaybeUninit; N]>`; the `into_inner` is safe because the inner - // array does not require initialization. - let mut buf: [MaybeUninit<u8>; 39] = unsafe { - MaybeUninit::uninitialized().into_inner() - }; + let mut buf = uninitialized_array![u8; 39]; let mut curr = buf.len() as isize; let buf_ptr = MaybeUninit::first_mut_ptr(&mut buf); let lut_ptr = DEC_DIGITS_LUT.as_ptr(); |
