Skip to content

Commit

Permalink
bevy_reflect: GetTypeRegistration for SmallVec<T> (bevyengine#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 authored and james7132 committed Oct 28, 2022
1 parent 619267f commit 8a487ac
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion crates/bevy_reflect/src/impls/smallvec.rs
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 8a487ac

Please sign in to comment.