Type Definition bevy::utils::HashSet [−]
pub type HashSet<K> = HashSet<K, RandomState>;
Expand description
A HashSet
implementing aHash
, a high
speed keyed hashing algorithm intended for use in in-memory hashmaps.
aHash
is designed for performance and is NOT cryptographically secure.
Construction
Users may be surprised when a HashSet
cannot be constructed with HashSet::new()
:
ⓘ
use bevy_utils::HashSet;
// Produces an error like "no function or associated item named `new` found [...]"
let map: HashSet<String> = HashSet::new();
The standard library’s HashSet::new
is
implemented only for HashSet
s which use the
DefaultHasher
, so it’s not
available for Bevy’s HashSet
.
However, an empty HashSet
can easily be constructed using the Default
implementation:
use bevy_utils::HashSet;
// This works!
let map: HashSet<String> = HashSet::default();
assert!(map.is_empty());