use std::hash::{Hash, Hasher};
use crate::logical::Registry;
use crate::raw::RegistryInfo;
#[derive(Copy, Clone, Debug, Eq)]
pub struct RegistryId {
get_registry_info: fn() -> RegistryInfo
}
impl RegistryId {
pub const fn of<R: Registry + ?Sized>() -> Self {
Self {
get_registry_info: RegistryInfo::of::<R>
}
}
pub fn info(&self) -> RegistryInfo {
(self.get_registry_info)()
}
}
impl PartialEq for RegistryId {
fn eq(&self, other: &Self) -> bool {
self.info().type_id() == other.info().type_id()
}
}
impl Hash for RegistryId {
fn hash<H: Hasher>(&self, state: &mut H) {
self.info().type_id().hash(state)
}
}