o3 0.62.0

shared-nothing primitives
Documentation
use std::ptr;

use crate::{base::marker::ThreadBound, mem};

/// Exclusive admission to initialize one empty owned cell.
#[derive(Debug)]
#[must_use]
#[repr(transparent)]
pub struct Vacant<'a, T> {
    pub(super) source: &'a mut Option<T>,
    pub(super) bound: ThreadBound,
}

impl<'a, T> Vacant<'a, T> {
    pub fn insert(self, value: T) -> mem::raw::Occupied<'a, T> {
        // SAFETY: the exclusive vacancy retains None; initializing it drops no value.
        unsafe { ptr::write(self.source, Some(value)) };
        mem::raw::Occupied {
            source: self.source,
            bound: ThreadBound::NEW,
        }
    }
}