Skip to content

Commit 7da97b4

Browse files
committed
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<T, E>`, `HashSet<T>`, and `Range<T>` 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
1 parent 880ea5d commit 7da97b4

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

crates/bevy_reflect/src/impls/smallvec.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use crate::{
99

1010
impl<T: smallvec::Array + Send + Sync + 'static> Array for SmallVec<T>
1111
where
12-
T::Item: FromReflect + Clone,
12+
T::Item: FromReflect,
1313
{
1414
fn get(&self, index: usize) -> Option<&dyn Reflect> {
1515
if index < SmallVec::len(self) {
@@ -41,7 +41,7 @@ where
4141

4242
impl<T: smallvec::Array + Send + Sync + 'static> List for SmallVec<T>
4343
where
44-
T::Item: FromReflect + Clone,
44+
T::Item: FromReflect,
4545
{
4646
fn push(&mut self, value: Box<dyn Reflect>) {
4747
let value = value.take::<T::Item>().unwrap_or_else(|value| {
@@ -58,7 +58,7 @@ where
5858

5959
impl<T: smallvec::Array + Send + Sync + 'static> Reflect for SmallVec<T>
6060
where
61-
T::Item: FromReflect + Clone,
61+
T::Item: FromReflect,
6262
{
6363
fn type_name(&self) -> &str {
6464
std::any::type_name::<Self>()
@@ -116,7 +116,7 @@ where
116116

117117
impl<T: smallvec::Array + Send + Sync + 'static> Typed for SmallVec<T>
118118
where
119-
T::Item: FromReflect + Clone,
119+
T::Item: FromReflect,
120120
{
121121
fn type_info() -> &'static TypeInfo {
122122
static CELL: GenericTypeInfoCell = GenericTypeInfoCell::new();
@@ -126,7 +126,7 @@ where
126126

127127
impl<T: smallvec::Array + Send + Sync + 'static> FromReflect for SmallVec<T>
128128
where
129-
T::Item: FromReflect + Clone,
129+
T::Item: FromReflect,
130130
{
131131
fn from_reflect(reflect: &dyn Reflect) -> Option<Self> {
132132
if let ReflectRef::List(ref_list) = reflect.reflect_ref() {
@@ -143,7 +143,7 @@ where
143143

144144
impl<T: smallvec::Array + Send + Sync + 'static> GetTypeRegistration for SmallVec<T>
145145
where
146-
T::Item: FromReflect + Clone,
146+
T::Item: FromReflect,
147147
{
148148
fn get_type_registration() -> TypeRegistration {
149149
let mut registration = TypeRegistration::of::<SmallVec<T>>();

crates/bevy_reflect/src/impls/std.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,8 +346,8 @@ impl<K: FromReflect + Eq + Hash, V: FromReflect> Typed for HashMap<K, V> {
346346

347347
impl<K, V> GetTypeRegistration for HashMap<K, V>
348348
where
349-
K: FromReflect + Clone + Eq + Hash,
350-
V: FromReflect + Clone,
349+
K: FromReflect + Eq + Hash,
350+
V: FromReflect,
351351
{
352352
fn get_type_registration() -> TypeRegistration {
353353
let mut registration = TypeRegistration::of::<HashMap<K, V>>();

0 commit comments

Comments
 (0)