use core::marker::PhantomData;
pub struct Handle<T> {
pub(crate) key: slotmap::DefaultKey,
_ty: PhantomData<fn() -> T>,
}
impl<T> Handle<T> {
pub(crate) fn from_key(key: slotmap::DefaultKey) -> Self {
Self {
key,
_ty: PhantomData,
}
}
}
impl<T> Clone for Handle<T> {
fn clone(&self) -> Self {
*self
}
}
impl<T> Copy for Handle<T> {}
impl<T> PartialEq for Handle<T> {
fn eq(&self, other: &Self) -> bool {
self.key == other.key
}
}
impl<T> Eq for Handle<T> {}
impl<T> core::hash::Hash for Handle<T> {
fn hash<H: core::hash::Hasher>(&self, state: &mut H) {
self.key.hash(state);
}
}
impl<T> core::fmt::Debug for Handle<T> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
f.debug_struct("Handle").field("key", &self.key).finish()
}
}