use crate::depot::{capacity, heap, index::Position};
#[repr(transparent)]
pub struct Vacant<'a, K: crate::depot::raw::Address, P: Ord, I: Position = u32, B = ()> {
pub(in crate::depot::heap) entry: heap::Vacancy<&'a mut keyed::Min<K, P, I, B>, K>,
}
use heap::keyed;
impl<K: crate::depot::raw::Address, P: Ord, I: Position, B> keyed::Vacant<'_, K, P, I, B> {
pub fn insert(self, priority: P) {
self.entry.prepare(priority).store();
}
}
impl<'a, 'h, K: crate::depot::raw::Address, P: Ord, I: Position>
keyed::Vacant<'a, K, P, I, capacity::Domain<'h>>
{
pub fn from_live<C>(live: keyed::Admission<'a, 'h, K, P, I, C, Self>) -> (Self, C) {
let ((heap, context), key) = live.into_inner();
let entry = unsafe { heap::Vacancy::new(heap, key.into_inner()) };
(Self { entry }, context)
}
}