
# Objective - Contributes to #16877 ## Solution - Moved `hashbrown`, `foldhash`, and related types out of `bevy_utils` and into `bevy_platform_support` - Refactored the above to match the layout of these types in `std`. - Updated crates as required. ## Testing - CI --- ## Migration Guide - The following items were moved out of `bevy_utils` and into `bevy_platform_support::hash`: - `FixedState` - `DefaultHasher` - `RandomState` - `FixedHasher` - `Hashed` - `PassHash` - `PassHasher` - `NoOpHash` - The following items were moved out of `bevy_utils` and into `bevy_platform_support::collections`: - `HashMap` - `HashSet` - `bevy_utils::hashbrown` has been removed. Instead, import from `bevy_platform_support::collections` _or_ take a dependency on `hashbrown` directly. - `bevy_utils::Entry` has been removed. Instead, import from `bevy_platform_support::collections::hash_map` or `bevy_platform_support::collections::hash_set` as appropriate. - All of the above equally apply to `bevy::utils` and `bevy::platform_support`. ## Notes - I left `PreHashMap`, `PreHashMapExt`, and `TypeIdMap` in `bevy_utils` as they might be candidates for micro-crating. They can always be moved into `bevy_platform_support` at a later date if desired.
65 lines
2.1 KiB
Rust
65 lines
2.1 KiB
Rust
//! Provides [`HashMap`] and [`HashSet`] from [`hashbrown`] with some customized defaults.\
|
|
//!
|
|
//! Also provides the [`HashTable`] type, which is specific to [`hashbrown`].
|
|
|
|
pub use hash_map::HashMap;
|
|
pub use hash_set::HashSet;
|
|
pub use hash_table::HashTable;
|
|
pub use hashbrown::Equivalent;
|
|
|
|
pub mod hash_map {
|
|
//! Provides [`HashMap`]
|
|
|
|
use crate::hash::FixedHasher;
|
|
use hashbrown::hash_map as hb;
|
|
|
|
// Re-exports to match `std::collections::hash_map`
|
|
pub use {
|
|
crate::hash::{DefaultHasher, RandomState},
|
|
hb::{
|
|
Drain, IntoIter, IntoKeys, IntoValues, Iter, IterMut, Keys, OccupiedEntry, VacantEntry,
|
|
Values, ValuesMut,
|
|
},
|
|
};
|
|
|
|
// Additional items from `hashbrown`
|
|
pub use hb::{
|
|
EntryRef, ExtractIf, OccupiedError, RawEntryBuilder, RawEntryBuilderMut, RawEntryMut,
|
|
RawOccupiedEntryMut,
|
|
};
|
|
|
|
/// Shortcut for [`HashMap`](hb::HashMap) with [`FixedHasher`] as the default hashing provider.
|
|
pub type HashMap<K, V, S = FixedHasher> = hb::HashMap<K, V, S>;
|
|
|
|
/// Shortcut for [`Entry`](hb::Entry) with [`FixedHasher`] as the default hashing provider.
|
|
pub type Entry<'a, K, V, S = FixedHasher> = hb::Entry<'a, K, V, S>;
|
|
}
|
|
|
|
pub mod hash_set {
|
|
//! Provides [`HashSet`]
|
|
|
|
use crate::hash::FixedHasher;
|
|
use hashbrown::hash_set as hb;
|
|
|
|
// Re-exports to match `std::collections::hash_set`
|
|
pub use hb::{Difference, Drain, Intersection, IntoIter, Iter, SymmetricDifference, Union};
|
|
|
|
// Additional items from `hashbrown`
|
|
pub use hb::{ExtractIf, OccupiedEntry, VacantEntry};
|
|
|
|
/// Shortcut for [`HashSet`](hb::HashSet) with [`FixedHasher`] as the default hashing provider.
|
|
pub type HashSet<T, S = FixedHasher> = hb::HashSet<T, S>;
|
|
|
|
/// Shortcut for [`Entry`](hb::Entry) with [`FixedHasher`] as the default hashing provider.
|
|
pub type Entry<'a, T, S = FixedHasher> = hb::Entry<'a, T, S>;
|
|
}
|
|
|
|
pub mod hash_table {
|
|
//! Provides [`HashTable`]
|
|
|
|
pub use hashbrown::hash_table::{
|
|
AbsentEntry, Drain, Entry, ExtractIf, HashTable, IntoIter, Iter, IterHash, IterHashMut,
|
|
IterMut, OccupiedEntry, VacantEntry,
|
|
};
|
|
}
|