turbo_tasks/registry/
registry_type.rs1use std::{any::TypeId, cell::SyncUnsafeCell, fmt::Debug};
2
3pub struct RegistryType {
4 pub global_name: &'static str,
6 pub name: &'static str,
8 pub type_id: TypeId,
10 pub(crate) id: SyncUnsafeCell<u16>,
12}
13
14impl Eq for RegistryType {}
15impl PartialEq for RegistryType {
16 fn eq(&self, other: &Self) -> bool {
17 self.type_id == other.type_id
18 }
19}
20
21impl Debug for RegistryType {
22 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
23 f.write_str(self.global_name)
24 }
25}
26
27impl RegistryType {
28 pub const fn new<T: 'static>(name: &'static str, global_name: &'static str) -> Self {
29 Self {
30 name,
31 global_name,
32 type_id: TypeId::of::<T>(),
33 id: SyncUnsafeCell::new(0),
34 }
35 }
36}