From ed7219b1485c4a8a44b821b6ddaa053a6150efe4 Mon Sep 17 00:00:00 2001 From: Gino Valente Date: Sat, 4 Jun 2022 15:18:03 -0700 Subject: [PATCH] Cleanup --- crates/bevy_reflect/src/enums/helpers.rs | 10 --- crates/bevy_reflect/src/enums/mod.rs | 82 ++++++++++++++---------- 2 files changed, 48 insertions(+), 44 deletions(-) diff --git a/crates/bevy_reflect/src/enums/helpers.rs b/crates/bevy_reflect/src/enums/helpers.rs index d7fe169cb4ecc8..c14913d19dede5 100644 --- a/crates/bevy_reflect/src/enums/helpers.rs +++ b/crates/bevy_reflect/src/enums/helpers.rs @@ -15,16 +15,6 @@ pub fn enum_hash(value: &TEnum) -> Option { Some(hasher.finish()) } -// TODO: Add serializable. How do we handle enums? -// pub fn enum_serialize(value: &TEnum, serializer: S) -> Result -// where -// TEnum: Enum + ?Sized, -// S: serde::Serializer, -// { -// -// -// } - /// Compares an [`Enum`] with a [`Reflect`] value. /// /// Returns true if and only if all of the following are true: diff --git a/crates/bevy_reflect/src/enums/mod.rs b/crates/bevy_reflect/src/enums/mod.rs index a32f134ae7c086..3364478d5c8aa2 100644 --- a/crates/bevy_reflect/src/enums/mod.rs +++ b/crates/bevy_reflect/src/enums/mod.rs @@ -445,58 +445,72 @@ mod tests { let a: &dyn Reflect = &TestEnum::A; let b: &dyn Reflect = &TestEnum::A; - assert!(a.reflect_partial_eq(b).unwrap_or_default(), "expected TestEnum::A == TestEnum::A"); + assert!( + a.reflect_partial_eq(b).unwrap_or_default(), + "expected TestEnum::A == TestEnum::A" + ); let a: &dyn Reflect = &TestEnum::A; let b: &dyn Reflect = &TestEnum::A1; - assert!(!a.reflect_partial_eq(b).unwrap_or_default(), "expected TestEnum::A != TestEnum::A1"); + assert!( + !a.reflect_partial_eq(b).unwrap_or_default(), + "expected TestEnum::A != TestEnum::A1" + ); let a: &dyn Reflect = &TestEnum::B(123); let b: &dyn Reflect = &TestEnum::B(123); - assert!(a.reflect_partial_eq(b).unwrap_or_default(), "expected TestEnum::B(123) == TestEnum::B(123)"); + assert!( + a.reflect_partial_eq(b).unwrap_or_default(), + "expected TestEnum::B(123) == TestEnum::B(123)" + ); let a: &dyn Reflect = &TestEnum::B(123); let b: &dyn Reflect = &TestEnum::B(321); - assert!(!a.reflect_partial_eq(b).unwrap_or_default(), "expected TestEnum::B(123) != TestEnum::B(321)"); + assert!( + !a.reflect_partial_eq(b).unwrap_or_default(), + "expected TestEnum::B(123) != TestEnum::B(321)" + ); let a: &dyn Reflect = &TestEnum::B(123); let b: &dyn Reflect = &TestEnum::B1(123); - assert!(!a.reflect_partial_eq(b).unwrap_or_default(), "expected TestEnum::B(123) != TestEnum::B1(123)"); + assert!( + !a.reflect_partial_eq(b).unwrap_or_default(), + "expected TestEnum::B(123) != TestEnum::B1(123)" + ); let a: &dyn Reflect = &TestEnum::B(123); let b: &dyn Reflect = &TestEnum::B2(123, 123); - assert!(!a.reflect_partial_eq(b).unwrap_or_default(), "expected TestEnum::B(123) != TestEnum::B2(123, 123)"); + assert!( + !a.reflect_partial_eq(b).unwrap_or_default(), + "expected TestEnum::B(123) != TestEnum::B2(123, 123)" + ); - let a: &dyn Reflect = &TestEnum::C { - value: 123 - }; - let b: &dyn Reflect = &TestEnum::C { - value: 123 - }; - assert!(a.reflect_partial_eq(b).unwrap_or_default(), "expected TestEnum::C{{value: 123}} == TestEnum::C{{value: 123}}"); + let a: &dyn Reflect = &TestEnum::C { value: 123 }; + let b: &dyn Reflect = &TestEnum::C { value: 123 }; + assert!( + a.reflect_partial_eq(b).unwrap_or_default(), + "expected TestEnum::C{{value: 123}} == TestEnum::C{{value: 123}}" + ); - let a: &dyn Reflect = &TestEnum::C { - value: 123 - }; - let b: &dyn Reflect = &TestEnum::C { - value: 321 - }; - assert!(!a.reflect_partial_eq(b).unwrap_or_default(), "expected TestEnum::C{{value: 123}} != TestEnum::C{{value: 321}}"); + let a: &dyn Reflect = &TestEnum::C { value: 123 }; + let b: &dyn Reflect = &TestEnum::C { value: 321 }; + assert!( + !a.reflect_partial_eq(b).unwrap_or_default(), + "expected TestEnum::C{{value: 123}} != TestEnum::C{{value: 321}}" + ); - let a: &dyn Reflect = &TestEnum::C { - value: 123 - }; - let b: &dyn Reflect = &TestEnum::C1 { - value: 123 - }; - assert!(!a.reflect_partial_eq(b).unwrap_or_default(), "expected TestEnum::C{{value: 123}} != TestEnum::C1{{value: 123}}"); + let a: &dyn Reflect = &TestEnum::C { value: 123 }; + let b: &dyn Reflect = &TestEnum::C1 { value: 123 }; + assert!( + !a.reflect_partial_eq(b).unwrap_or_default(), + "expected TestEnum::C{{value: 123}} != TestEnum::C1{{value: 123}}" + ); - let a: &dyn Reflect = &TestEnum::C { - value: 123 - }; - let b: &dyn Reflect = &TestEnum::C2 { - value: 1.23 - }; - assert!(!a.reflect_partial_eq(b).unwrap_or_default(), "expected TestEnum::C{{value: 123}} != TestEnum::C2{{value: 1.23}}"); + let a: &dyn Reflect = &TestEnum::C { value: 123 }; + let b: &dyn Reflect = &TestEnum::C2 { value: 1.23 }; + assert!( + !a.reflect_partial_eq(b).unwrap_or_default(), + "expected TestEnum::C{{value: 123}} != TestEnum::C2{{value: 1.23}}" + ); } }