mirror of
https://github.com/guilhermewerner/reflection
synced 2025-06-15 13:14:19 +00:00
24 lines
389 B
Rust
24 lines
389 B
Rust
use std::any::{type_name, TypeId};
|
|
|
|
pub struct Class {
|
|
id: TypeId,
|
|
name: &'static str,
|
|
}
|
|
|
|
impl Class {
|
|
pub fn New<T: 'static>() -> Self {
|
|
Self {
|
|
id: TypeId::of::<T>(),
|
|
name: type_name::<T>().into(),
|
|
}
|
|
}
|
|
|
|
pub fn GetId(&self) -> TypeId {
|
|
self.id
|
|
}
|
|
|
|
pub fn GetName(&self) -> &'static str {
|
|
self.name
|
|
}
|
|
}
|