From de2b1a4e94fc5e4f16b0b98f5a4280b0646d8fec Mon Sep 17 00:00:00 2001 From: MrGVSV Date: Tue, 17 May 2022 23:45:09 +0000 Subject: [PATCH] bevy_reflect: Reflected char (#4790) # Objective `char` isn't reflected. ## Solution Reflected `char`. --- ## Changelog * Reflected `char` ## Migration Guide > List too long to display --- crates/bevy_reflect/src/impls/std.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/crates/bevy_reflect/src/impls/std.rs b/crates/bevy_reflect/src/impls/std.rs index f678627c4a410..2bd11c035a10b 100644 --- a/crates/bevy_reflect/src/impls/std.rs +++ b/crates/bevy_reflect/src/impls/std.rs @@ -16,6 +16,7 @@ use std::{ }; impl_reflect_value!(bool(Hash, PartialEq, Serialize, Deserialize)); +impl_reflect_value!(char(Hash, PartialEq, Serialize, Deserialize)); impl_reflect_value!(u8(Hash, PartialEq, Serialize, Deserialize)); impl_reflect_value!(u16(Hash, PartialEq, Serialize, Deserialize)); impl_reflect_value!(u32(Hash, PartialEq, Serialize, Deserialize)); @@ -37,6 +38,7 @@ impl_reflect_value!(Range Deserialize<'de> + Sen impl_reflect_value!(Duration(Hash, PartialEq, Serialize, Deserialize)); impl_from_reflect_value!(bool); +impl_from_reflect_value!(char); impl_from_reflect_value!(u8); impl_from_reflect_value!(u16); impl_from_reflect_value!(u32); @@ -552,6 +554,15 @@ mod tests { assert!(std::time::Duration::ZERO.serializable().is_some()); } + #[test] + fn should_partial_eq_char() { + let a: &dyn Reflect = &'x'; + let b: &dyn Reflect = &'x'; + let c: &dyn Reflect = &'o'; + assert!(a.reflect_partial_eq(b).unwrap_or_default()); + assert!(!a.reflect_partial_eq(c).unwrap_or_default()); + } + #[test] fn should_partial_eq_i32() { let a: &dyn Reflect = &123_i32;