lyra-engine/lyra-ecs/src/component_info.rs

18 lines
398 B
Rust
Raw Normal View History

2023-11-25 23:43:11 +00:00
use std::{any::{TypeId, type_name}, alloc::Layout};
#[derive(Clone, Debug)]
pub struct ComponentInfo {
pub type_id: TypeId,
pub name: String,
pub layout: Layout,
}
impl ComponentInfo {
pub fn new<T: 'static>() -> Self {
Self {
type_id: TypeId::of::<T>(),
name: type_name::<T>().to_string(),
layout: Layout::new::<T>(),
}
}
}