1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
use array::Array;
use std::mem::ManuallyDrop;
use std::ops::{Deref, DerefMut};
#[repr(C)]
pub union MaybeUninit<A: Array> {
empty: (),
value: ManuallyDrop<A>,
}
impl<A: Array> MaybeUninit<A> {
pub unsafe fn uninitialized() -> Self {
MaybeUninit { empty: () }
}
}
impl<A: Array> Deref for MaybeUninit<A> {
type Target = A;
#[inline(always)]
fn deref(&self) -> &A {
unsafe { &self.value }
}
}
impl<A: Array> DerefMut for MaybeUninit<A> {
#[inline(always)]
fn deref_mut(&mut self) -> &mut A {
unsafe { &mut self.value }
}
}