use crate::depot::heap::{self, hole};
pub struct Vacancy<S, V = ()> {
pub(in crate::depot) owner: S,
pub(in crate::depot) value: V,
}
impl<S: hole::raw::Source, V> Vacancy<S, V> {
pub(in crate::depot) unsafe fn new(owner: S, value: V) -> Self {
Self { owner, value }
}
}
impl<S: hole::raw::Source> Vacancy<S, S::Value> {
pub fn store(self) {
heap::raw::Hole::append(self).commit::<true>();
}
}
impl<'a, S, K> Vacancy<&'a mut S, K> {
pub(in crate::depot) fn prepare(
self,
priority: S::Priority,
) -> Vacancy<&'a mut S, heap::Stored<K, S::Priority>>
where
S: heap::raw::Store<Key = K>,
K: crate::depot::raw::Address,
{
Vacancy {
owner: self.owner,
value: heap::Stored {
identity: self.value,
priority,
},
}
}
}
impl<S, V> Vacancy<S, V> {
pub(in crate::depot) fn into_inner(self) -> (S, V) {
(self.owner, self.value)
}
}