1 | use std::any::TypeId; |
---|---|
2 | |
3 | #[repr(C)] |
4 | pub struct TaggedObject<T> { |
5 | type_id: TypeId, |
6 | pub(crate) object: Option<T>, |
7 | } |
8 | |
9 | impl<T: 'static> TaggedObject<T> { |
10 | pub fn new(object: T) -> Self { |
11 | TaggedObject { |
12 | type_id: TypeId::of::<T>(), |
13 | object: Some(object), |
14 | } |
15 | } |
16 | } |
17 |