mirror of
https://github.com/bevyengine/bevy
synced 2024-11-10 07:04:33 +00:00
Implement TypePath for EntityHash (#11195)
# Objective - Fix #11117 by implementing `Reflect` for `EntityHashMap` ## Solution - By implementing `TypePath` for `EntityHash`, Bevy will automatically implement `Reflect` for `EntityHashMap` --- ## Changelog - `TypePath` is implemented for `EntityHash` - A test called `entity_hashmap_should_impl_reflect` was created to verify that #11117 was solved.
This commit is contained in:
parent
99c43fabdf
commit
fe68005f71
1 changed files with 10 additions and 1 deletions
|
@ -80,6 +80,7 @@ impl_reflect_value!(isize(
|
||||||
impl_reflect_value!(f32(Debug, PartialEq, Serialize, Deserialize, Default));
|
impl_reflect_value!(f32(Debug, PartialEq, Serialize, Deserialize, Default));
|
||||||
impl_reflect_value!(f64(Debug, PartialEq, Serialize, Deserialize, Default));
|
impl_reflect_value!(f64(Debug, PartialEq, Serialize, Deserialize, Default));
|
||||||
impl_type_path!(str);
|
impl_type_path!(str);
|
||||||
|
impl_type_path!(::bevy_utils::EntityHash);
|
||||||
impl_reflect_value!(::alloc::string::String(
|
impl_reflect_value!(::alloc::string::String(
|
||||||
Debug,
|
Debug,
|
||||||
Hash,
|
Hash,
|
||||||
|
@ -1513,8 +1514,8 @@ mod tests {
|
||||||
Enum, FromReflect, Reflect, ReflectSerialize, TypeInfo, TypeRegistry, Typed, VariantInfo,
|
Enum, FromReflect, Reflect, ReflectSerialize, TypeInfo, TypeRegistry, Typed, VariantInfo,
|
||||||
VariantType,
|
VariantType,
|
||||||
};
|
};
|
||||||
use bevy_utils::HashMap;
|
|
||||||
use bevy_utils::{Duration, Instant};
|
use bevy_utils::{Duration, Instant};
|
||||||
|
use bevy_utils::{EntityHashMap, HashMap};
|
||||||
use std::f32::consts::{PI, TAU};
|
use std::f32::consts::{PI, TAU};
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
|
@ -1723,4 +1724,12 @@ mod tests {
|
||||||
let output = <&'static Path as FromReflect>::from_reflect(&path).unwrap();
|
let output = <&'static Path as FromReflect>::from_reflect(&path).unwrap();
|
||||||
assert_eq!(path, output);
|
assert_eq!(path, output);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn entity_hashmap_should_impl_reflect() {
|
||||||
|
let entity_map = bevy_utils::EntityHashMap::<i32, i32>::default();
|
||||||
|
let entity_map_type_info =
|
||||||
|
<EntityHashMap<_, _> as Reflect>::get_represented_type_info(&entity_map);
|
||||||
|
assert!(entity_map_type_info.is_some());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue