Path: blob/main/crates/bevy_reflect/src/impls/hashbrown.rs
6599 views
use crate::impls::macros::{impl_reflect_for_hashmap, impl_reflect_for_hashset};1#[cfg(feature = "functions")]2use crate::{3from_reflect::FromReflect, type_info::MaybeTyped, type_path::TypePath,4type_registry::GetTypeRegistration,5};6use bevy_reflect_derive::impl_type_path;7#[cfg(feature = "functions")]8use core::hash::{BuildHasher, Hash};910impl_reflect_for_hashmap!(hashbrown::hash_map::HashMap<K, V, S>);11impl_type_path!(::hashbrown::hash_map::HashMap<K, V, S>);12#[cfg(feature = "functions")]13crate::func::macros::impl_function_traits!(::hashbrown::hash_map::HashMap<K, V, S>;14<15K: FromReflect + MaybeTyped + TypePath + GetTypeRegistration + Eq + Hash,16V: FromReflect + MaybeTyped + TypePath + GetTypeRegistration,17S: TypePath + BuildHasher + Default + Send + Sync18>19);2021impl_reflect_for_hashset!(::hashbrown::hash_set::HashSet<V,S>);22impl_type_path!(::hashbrown::hash_set::HashSet<V, S>);23#[cfg(feature = "functions")]24crate::func::macros::impl_function_traits!(::hashbrown::hash_set::HashSet<V, S>;25<26V: Hash + Eq + FromReflect + TypePath + GetTypeRegistration,27S: TypePath + BuildHasher + Default + Send + Sync28>29);3031#[cfg(test)]32mod tests {33use crate::Reflect;34use static_assertions::assert_impl_all;3536#[test]37fn should_reflect_hashmaps() {38// We specify `foldhash::fast::RandomState` directly here since without the `default-hasher`39// feature, hashbrown uses an empty enum to force users to specify their own40assert_impl_all!(hashbrown::HashMap<u32, f32, foldhash::fast::RandomState>: Reflect);41}42}434445