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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
pub mod mem {
#[cfg(not(feature = "const-fn"))]
pub use core::mem;
pub use core::mem::{replace, zeroed, ManuallyDrop};
#[cfg(feature = "const-fn")]
pub union MaybeUninit<T> {
uninit: (),
value: ManuallyDrop<T>,
}
#[cfg(not(feature = "const-fn"))]
pub struct MaybeUninit<T> {
value: ManuallyDrop<T>,
}
impl<T> MaybeUninit<T> {
#[cfg(feature = "const-fn")]
pub const unsafe fn uninitialized() -> Self {
MaybeUninit { uninit: () }
}
#[cfg(not(feature = "const-fn"))]
pub unsafe fn uninitialized() -> Self {
mem::uninitialized()
}
pub unsafe fn get_ref(&self) -> &T {
&*self.value
}
pub unsafe fn get_mut(&mut self) -> &mut T {
&mut *self.value
}
}
}