From 585c14687009347fa9654dd3b1068486c1bffe4c Mon Sep 17 00:00:00 2001 From: Gino Valente Date: Wed, 24 Aug 2022 21:21:11 +0000 Subject: [PATCH] bevy_reflect: Remove unnecessary `Clone` bounds (#5783) # Objective Some of the reflection impls for container types had unnecessary `Clone` bounds on their generic arguments. These come from before `FromReflect` when types were instead bound by `Reflect + Clone`. With `FromReflect` this is no longer necessary. ## Solution Removed all leftover `Clone` bounds from types that use `FromReflect` instead. ## Note I skipped `Result`, `HashSet`, and `Range` since those do not use `FromReflect`. This should probably be handled in a separate PR since it would be a breaking change. --- ## Changelog - Remove unnecessary `Clone` bounds on reflected containers --- crates/bevy_reflect/src/impls/smallvec.rs | 12 ++++++------ crates/bevy_reflect/src/impls/std.rs | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/crates/bevy_reflect/src/impls/smallvec.rs b/crates/bevy_reflect/src/impls/smallvec.rs index 161e0312049b2b..918f74d40cc097 100644 --- a/crates/bevy_reflect/src/impls/smallvec.rs +++ b/crates/bevy_reflect/src/impls/smallvec.rs @@ -9,7 +9,7 @@ use crate::{ impl Array for SmallVec where - T::Item: FromReflect + Clone, + T::Item: FromReflect, { fn get(&self, index: usize) -> Option<&dyn Reflect> { if index < SmallVec::len(self) { @@ -41,7 +41,7 @@ where impl List for SmallVec where - T::Item: FromReflect + Clone, + T::Item: FromReflect, { fn push(&mut self, value: Box) { let value = value.take::().unwrap_or_else(|value| { @@ -58,7 +58,7 @@ where impl Reflect for SmallVec where - T::Item: FromReflect + Clone, + T::Item: FromReflect, { fn type_name(&self) -> &str { std::any::type_name::() @@ -116,7 +116,7 @@ where impl Typed for SmallVec where - T::Item: FromReflect + Clone, + T::Item: FromReflect, { fn type_info() -> &'static TypeInfo { static CELL: GenericTypeInfoCell = GenericTypeInfoCell::new(); @@ -126,7 +126,7 @@ where impl FromReflect for SmallVec where - T::Item: FromReflect + Clone, + T::Item: FromReflect, { fn from_reflect(reflect: &dyn Reflect) -> Option { if let ReflectRef::List(ref_list) = reflect.reflect_ref() { @@ -143,7 +143,7 @@ where impl GetTypeRegistration for SmallVec where - T::Item: FromReflect + Clone, + T::Item: FromReflect, { fn get_type_registration() -> TypeRegistration { let mut registration = TypeRegistration::of::>(); diff --git a/crates/bevy_reflect/src/impls/std.rs b/crates/bevy_reflect/src/impls/std.rs index 693ca39d7e88e9..f89c4855ccb36c 100644 --- a/crates/bevy_reflect/src/impls/std.rs +++ b/crates/bevy_reflect/src/impls/std.rs @@ -346,8 +346,8 @@ impl Typed for HashMap { impl GetTypeRegistration for HashMap where - K: FromReflect + Clone + Eq + Hash, - V: FromReflect + Clone, + K: FromReflect + Eq + Hash, + V: FromReflect, { fn get_type_registration() -> TypeRegistration { let mut registration = TypeRegistration::of::>();