Remove unnecessary impl_reflect_for_btree_map macro (#12146)

# Objective

To remove the `impl_reflect_for_btree_map` macro as per #12140.

## Solution

Replaced the `impl_reflect_for_btree_map` macro.
This commit is contained in:
Antony 2024-02-26 20:04:11 -05:00 committed by GitHub
parent f7f7e326e5
commit fd0f1a37ad
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -622,13 +622,11 @@ impl_type_path!(::bevy_utils::hashbrown::hash_map::DefaultHashBuilder);
impl_type_path!(::bevy_utils::NoOpHash);
impl_type_path!(::bevy_utils::hashbrown::HashMap<K, V, S>);
macro_rules! impl_reflect_for_btree_map {
($ty:path) => {
impl<K, V> Map for $ty
where
impl<K, V> Map for ::std::collections::BTreeMap<K, V>
where
K: FromReflect + TypePath + Eq + Ord,
V: FromReflect + TypePath,
{
{
fn get(&self, key: &dyn Reflect) -> Option<&dyn Reflect> {
key.downcast_ref::<K>()
.and_then(|key| Self::get(self, key))
@ -718,13 +716,13 @@ macro_rules! impl_reflect_for_btree_map {
.and_then(|key| self.remove(key))
.map(|value| Box::new(value) as Box<dyn Reflect>)
}
}
}
impl<K, V> Reflect for $ty
where
impl<K, V> Reflect for ::std::collections::BTreeMap<K, V>
where
K: FromReflect + TypePath + Eq + Ord,
V: FromReflect + TypePath,
{
{
fn get_represented_type_info(&self) -> Option<&'static TypeInfo> {
Some(<Self as Typed>::type_info())
}
@ -786,36 +784,36 @@ macro_rules! impl_reflect_for_btree_map {
fn reflect_partial_eq(&self, value: &dyn Reflect) -> Option<bool> {
map_partial_eq(self, value)
}
}
}
impl<K, V> Typed for $ty
where
impl<K, V> Typed for ::std::collections::BTreeMap<K, V>
where
K: FromReflect + TypePath + Eq + Ord,
V: FromReflect + TypePath,
{
{
fn type_info() -> &'static TypeInfo {
static CELL: GenericTypeInfoCell = GenericTypeInfoCell::new();
CELL.get_or_insert::<Self, _>(|| TypeInfo::Map(MapInfo::new::<Self, K, V>()))
}
}
}
impl<K, V> GetTypeRegistration for $ty
where
impl<K, V> GetTypeRegistration for ::std::collections::BTreeMap<K, V>
where
K: FromReflect + TypePath + Eq + Ord,
V: FromReflect + TypePath,
{
{
fn get_type_registration() -> TypeRegistration {
let mut registration = TypeRegistration::of::<Self>();
registration.insert::<ReflectFromPtr>(FromType::<Self>::from_type());
registration
}
}
}
impl<K, V> FromReflect for $ty
where
impl<K, V> FromReflect for ::std::collections::BTreeMap<K, V>
where
K: FromReflect + TypePath + Eq + Ord,
V: FromReflect + TypePath,
{
{
fn from_reflect(reflect: &dyn Reflect) -> Option<Self> {
if let ReflectRef::Map(ref_map) = reflect.reflect_ref() {
let mut new_map = Self::new();
@ -829,11 +827,8 @@ macro_rules! impl_reflect_for_btree_map {
None
}
}
}
};
}
impl_reflect_for_btree_map!(::std::collections::BTreeMap<K, V>);
impl_type_path!(::std::collections::BTreeMap<K, V>);
impl<T: Reflect + TypePath, const N: usize> Array for [T; N] {