o3 0.16.1

shared-nothing primitives
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use std::mem;

#[repr(transparent)]
pub(crate) struct Slots<T, const N: usize>([mem::MaybeUninit<T>; N]);

impl<T, const N: usize> Slots<T, N> {
    pub(super) const fn new() -> Self {
        Self([const { mem::MaybeUninit::uninit() }; N])
    }

    pub(super) fn write(&mut self, index: usize, value: T) {
        self.0[index].write(value);
    }

    pub(super) fn take(&mut self, index: usize) -> T {
        unsafe { self.0[index].assume_init_read() }
    }
}