Skip to content

Commit

Permalink
bevy_reflect: GetTypeRegistration for SmallVec<T> (#5782)
Browse files Browse the repository at this point in the history
# Objective

`SmallVec<T>` was missing a `GetTypeRegistration` impl.

## Solution

Added a `GetTypeRegistration` impl.

---

## Changelog

* Added a `GetTypeRegistration` impl for `SmallVec<T>`
  • Loading branch information
MrGVSV committed Aug 24, 2022
1 parent 3d194a2 commit 886837d
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion crates/bevy_reflect/src/impls/smallvec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ use std::any::Any;

use crate::utility::GenericTypeInfoCell;
use crate::{
Array, ArrayIter, FromReflect, List, ListInfo, Reflect, ReflectMut, ReflectRef, TypeInfo, Typed,
Array, ArrayIter, FromReflect, FromType, GetTypeRegistration, List, ListInfo, Reflect,
ReflectFromPtr, ReflectMut, ReflectRef, TypeInfo, TypeRegistration, Typed,
};

impl<T: smallvec::Array + Send + Sync + 'static> Array for SmallVec<T>
Expand Down Expand Up @@ -139,3 +140,14 @@ where
}
}
}

impl<T: smallvec::Array + Send + Sync + 'static> GetTypeRegistration for SmallVec<T>
where
T::Item: FromReflect + Clone,
{
fn get_type_registration() -> TypeRegistration {
let mut registration = TypeRegistration::of::<SmallVec<T>>();
registration.insert::<ReflectFromPtr>(FromType::<SmallVec<T>>::from_type());
registration
}
}

0 comments on commit 886837d

Please sign in to comment.