Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
bevyengine
GitHub Repository: bevyengine/bevy
Path: blob/main/crates/bevy_reflect/src/impls/hashbrown.rs
6599 views
1
use crate::impls::macros::{impl_reflect_for_hashmap, impl_reflect_for_hashset};
2
#[cfg(feature = "functions")]
3
use crate::{
4
from_reflect::FromReflect, type_info::MaybeTyped, type_path::TypePath,
5
type_registry::GetTypeRegistration,
6
};
7
use bevy_reflect_derive::impl_type_path;
8
#[cfg(feature = "functions")]
9
use core::hash::{BuildHasher, Hash};
10
11
impl_reflect_for_hashmap!(hashbrown::hash_map::HashMap<K, V, S>);
12
impl_type_path!(::hashbrown::hash_map::HashMap<K, V, S>);
13
#[cfg(feature = "functions")]
14
crate::func::macros::impl_function_traits!(::hashbrown::hash_map::HashMap<K, V, S>;
15
<
16
K: FromReflect + MaybeTyped + TypePath + GetTypeRegistration + Eq + Hash,
17
V: FromReflect + MaybeTyped + TypePath + GetTypeRegistration,
18
S: TypePath + BuildHasher + Default + Send + Sync
19
>
20
);
21
22
impl_reflect_for_hashset!(::hashbrown::hash_set::HashSet<V,S>);
23
impl_type_path!(::hashbrown::hash_set::HashSet<V, S>);
24
#[cfg(feature = "functions")]
25
crate::func::macros::impl_function_traits!(::hashbrown::hash_set::HashSet<V, S>;
26
<
27
V: Hash + Eq + FromReflect + TypePath + GetTypeRegistration,
28
S: TypePath + BuildHasher + Default + Send + Sync
29
>
30
);
31
32
#[cfg(test)]
33
mod tests {
34
use crate::Reflect;
35
use static_assertions::assert_impl_all;
36
37
#[test]
38
fn should_reflect_hashmaps() {
39
// We specify `foldhash::fast::RandomState` directly here since without the `default-hasher`
40
// feature, hashbrown uses an empty enum to force users to specify their own
41
assert_impl_all!(hashbrown::HashMap<u32, f32, foldhash::fast::RandomState>: Reflect);
42
}
43
}
44
45