diff options
Diffstat (limited to 'engine-reflection/src/lib.rs')
| -rw-r--r-- | engine-reflection/src/lib.rs | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/engine-reflection/src/lib.rs b/engine-reflection/src/lib.rs index dabf4b9..b48ecfe 100644 --- a/engine-reflection/src/lib.rs +++ b/engine-reflection/src/lib.rs @@ -45,6 +45,7 @@ pub enum Type Array(Array), Slice(Slice), Literal(Literal), + Reference(Reference), } impl Type @@ -72,7 +73,7 @@ impl Type Self::Struct(struct_type) => struct_type.default_value(), Self::Enum(enum_type) => enum_type.default_value(), Self::Literal(literal_type) => literal_type.default_value(), - Self::Array(_) | Self::Slice(_) => None, + Self::Array(_) | Self::Slice(_) | Self::Reference(_) => None, } } @@ -83,7 +84,7 @@ impl Type Self::Struct(struct_type) => struct_type.has_default_value(), Self::Enum(enum_type) => enum_type.has_default_value(), Self::Literal(literal_type) => literal_type.has_default_value(), - Self::Array(_) | Self::Slice(_) => false, + Self::Array(_) | Self::Slice(_) | Self::Reference(_) => false, } } } @@ -281,6 +282,12 @@ impl Literal } } +#[derive(Debug)] +pub struct Reference +{ + pub ty: &'static Type, +} + #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] #[non_exhaustive] pub enum LiteralType @@ -375,6 +382,11 @@ unsafe impl<T: Reflection> Reflection for &'static [T] }); } +unsafe impl<T: Reflection> Reflection for &'static T +{ + const TYPE_REFLECTION: &Type = &Type::Reference(Reference { ty: T::TYPE_REFLECTION }); +} + #[derive(Clone)] pub struct FnWithDebug<Value> { |
