Skip to content

Mention that users need to change HashMap and HashSet initializations in 0.16 #2045

@janhohenheim

Description

@janhohenheim

Discord discussion

Methods that are affected:

  • new -> default
  • from -> from_iter
  • possibly others? Note from @Victoronz: "To find every DefaultHashBuilder specific impl, the docs of hashbrown should be easily searchable"

Examples

use bevy::platform_support::collections::HashMap;

struct SomeHashMap(HashMap<u32, u32>);

fn main() {
    // This fails to compile (same for HashSet):
    let some_hash_map = SomeHashMap(HashMap::new());

    // This works fine (same for HashSet):
    let some_hash_map = SomeHashMap(HashMap::default());
}

And

use bevy::platform_support::collections::HashSet;

struct SomeHashSet(HashSet<u32>);

fn main() {
    // This fails to compile:
    let some_hash_set = SomeHashSet(HashSet::from([1, 2, 3]));

    // This works fine:
    let some_hash_set = SomeHashSet(HashSet::from_iter([1, 2, 3]));
}

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions