use std::{marker, ops};
use crate::depot::{
arena::slab::key,
queue::{indexed::slab, links},
};
#[repr(transparent)]
pub(in crate::depot::queue::group) struct Node<Tag>(
links::Index,
marker::PhantomData<key::Handle<Tag, { u32::MAX }, true>>,
);
impl<Tag> Node<Tag> {
pub(in crate::depot::queue::group) fn new(index: links::Index) -> Self {
Self(index, marker::PhantomData)
}
pub(in crate::depot::queue::group) fn index(&self) -> links::Index {
self.0
}
pub(in crate::depot::queue::group) fn inserted(
key: key::Handle<Tag, { u32::MAX }, true>,
) -> Self {
Self::new(links::Index::from(key))
}
pub(in crate::depot::queue::group) fn bind<T, H, const N: usize, C, S>(
&self,
source: S,
) -> S::Output
where
H: crate::depot::raw::IndexedHook,
C: crate::depot::raw::Count,
S: ops::Deref<Target = slab::Slab<T, Tag, { u32::MAX }, H, N, C>>
+ crate::depot::raw::Project<links::Index, H>,
{
unsafe { source.project(self.0) }
}
}
const _: () = {
assert!(size_of::<Node<()>>() == size_of::<links::Index>());
assert!(size_of::<Option<Node<()>>>() == size_of::<links::Index>());
};