diff --git a/crates/bevy_reflect/Cargo.toml b/crates/bevy_reflect/Cargo.toml index 16d2eef4c2..4202293037 100644 --- a/crates/bevy_reflect/Cargo.toml +++ b/crates/bevy_reflect/Cargo.toml @@ -41,6 +41,7 @@ rmp-serde = "1.1" bincode = "1.3" serde_json = "1.0" serde = { version = "1", features = ["derive"] } +static_assertions = "1.1.0" [[example]] name = "reflect_docs" diff --git a/crates/bevy_reflect/src/impls/std.rs b/crates/bevy_reflect/src/impls/std.rs index de42d0ca3f..5dcfa9e375 100644 --- a/crates/bevy_reflect/src/impls/std.rs +++ b/crates/bevy_reflect/src/impls/std.rs @@ -1516,9 +1516,13 @@ mod tests { }; use bevy_utils::{Duration, Instant}; use bevy_utils::{EntityHashMap, HashMap}; + use static_assertions::assert_impl_all; use std::f32::consts::{PI, TAU}; use std::path::Path; + // EntityHashMap should implement Reflect + assert_impl_all!(EntityHashMap: Reflect); + #[test] fn can_serialize_duration() { let mut type_registry = TypeRegistry::default(); @@ -1599,6 +1603,8 @@ mod tests { #[test] fn option_should_impl_enum() { + assert_impl_all!(Option<()>: Enum); + let mut value = Some(123usize); assert!(value @@ -1672,6 +1678,8 @@ mod tests { #[test] fn option_should_impl_typed() { + assert_impl_all!(Option<()>: Typed); + type MyOption = Option; let info = MyOption::type_info(); if let TypeInfo::Enum(info) = info { @@ -1702,6 +1710,7 @@ mod tests { panic!("Expected `TypeInfo::Enum`"); } } + #[test] fn nonzero_usize_impl_reflect_from_reflect() { let a: &dyn Reflect = &std::num::NonZeroUsize::new(42).unwrap(); @@ -1724,12 +1733,4 @@ mod tests { let output = <&'static Path as FromReflect>::from_reflect(&path).unwrap(); assert_eq!(path, output); } - - #[test] - fn entity_hashmap_should_impl_reflect() { - let entity_map = bevy_utils::EntityHashMap::::default(); - let entity_map_type_info = - as Reflect>::get_represented_type_info(&entity_map); - assert!(entity_map_type_info.is_some()); - } }