From 24b319f6ec9b6f3fdd4dc366b480b056900ab3ed Mon Sep 17 00:00:00 2001 From: Charles Bournhonesque Date: Fri, 15 Mar 2024 13:43:26 -0400 Subject: [PATCH] Add reflect for type id (#12495) # Objective Add reflect for `std::any::TypeId`. I couldn't add ReflectSerialize/ReflectDeserialize for it, it was giving me an error. I don't really understand why, since it works for `std::path::PathBuf`. Co-authored-by: Charles Bournhonesque --- crates/bevy_reflect/src/impls/std.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/crates/bevy_reflect/src/impls/std.rs b/crates/bevy_reflect/src/impls/std.rs index 578879091bfcc..c35ec3d40ca34 100644 --- a/crates/bevy_reflect/src/impls/std.rs +++ b/crates/bevy_reflect/src/impls/std.rs @@ -96,6 +96,7 @@ impl_reflect_value!(::std::path::PathBuf( Deserialize, Default )); +impl_reflect_value!(::std::any::TypeId(Debug, Hash, PartialEq,)); impl_reflect_value!( ::core::result::Result < T: Clone + Reflect + TypePath, E: Clone + Reflect + TypePath > () @@ -2104,6 +2105,13 @@ mod tests { assert_eq!(path, output); } + #[test] + fn type_id_should_from_reflect() { + let type_id = std::any::TypeId::of::(); + let output = ::from_reflect(&type_id).unwrap(); + assert_eq!(type_id, output); + } + #[test] fn static_str_should_from_reflect() { let expected = "Hello, World!";