o3 0.62.0

shared-nothing primitives
Documentation
use crate::{
    base::num::bounded,
    depot::{
        arena::hash::{self, runtime::entry},
        map,
        queue::links,
    },
};
use std::mem;

/// A vacant value and directory bucket belonging to one exclusive owner.
pub struct Vacancy<'a, T, Tag> {
    pub(in crate::depot::arena::hash) core: &'a mut hash::raw::Core<T, Tag>,
    pub(in crate::depot::arena::hash) index: bounded::raw::U32<0, { u32::MAX - 1 }>,
    pub(in crate::depot::arena::hash) bucket: map::raw::Vacant,
    pub(in crate::depot::arena::hash) hash: u64,
}

const _: () = {
    assert!(mem::size_of::<Vacancy<'static, (), ()>>() == mem::size_of::<(&(), u64, u32, u32)>());
    assert!(
        mem::size_of::<Option<Vacancy<'static, (), ()>>>()
            == mem::size_of::<Vacancy<'static, (), ()>>()
    );
};

impl<'a, T, Tag> Vacancy<'a, T, Tag> {
    /// Returns the slot reserved for this insertion.
    ///
    /// This vacancy retains exclusive access until insertion or drop; the index
    /// alone does not establish an initialized value.
    pub fn index(&self) -> links::Index {
        self.index.into()
    }

    pub fn insert(self, value: T) -> entry::Live<'a, T, Tag, entry::Occupied> {
        hash::raw::insert(self, value)
    }
}