logo

Type Definition bevy::utils::HashMap[]

pub type HashMap<K, V> = HashMap<K, V, RandomState>;
Expand description

A HashMap 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 HashMap cannot be constructed with HashMap::new():

use bevy_utils::HashMap;

// Produces an error like "no function or associated item named `new` found [...]"
let map: HashMap<String, String> = HashMap::new();

The standard library’s HashMap::new is implemented only for HashMaps which use the DefaultHasher, so it’s not available for Bevy’s HashMap.

However, an empty HashMap can easily be constructed using the Default implementation:

use bevy_utils::HashMap;

// This works!
let map: HashMap<String, String> = HashMap::default();
assert!(map.is_empty());