1
2
3
4
5
6
7
8
9
pub union Slot<T> { x: T }

impl<T> From<T> for Slot<T> { fn from(x: T) -> Self { Slot { x: x } } }

impl<T> Slot<T> {
    unsafe fn as_ref(&self) -> &T { &self.x }
    unsafe fn as_mut(&mut self) -> &mut T { &mut self.x }
    unsafe fn unwrap(self) -> T { self.x }
}