Skip to content

Commit

Permalink
Make EntityHashMap::new and EntityHashSet::new const (#17615)
Browse files Browse the repository at this point in the history
# Objective

#16912 turned `EntityHashMap` and `EntityHashSet` into proper newtypes
instead of type aliases. However, this removed the ability to create
these collections in const contexts; previously, you could use
`EntityHashSet::with_hasher(EntityHash)`, but it doesn't exist anymore.

## Solution

Make `EntityHashMap::new` and `EntityHashSet::new` const methods.
  • Loading branch information
Jondolf authored Jan 30, 2025
1 parent 7d68ac0 commit 59697f9
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion crates/bevy_ecs/src/entity/hash_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ impl<V> EntityHashMap<V> {
/// Equivalent to [`HashMap::with_hasher(EntityHash)`].
///
/// [`HashMap::with_hasher(EntityHash)`]: HashMap::with_hasher
pub fn new() -> Self {
pub const fn new() -> Self {
Self(HashMap::with_hasher(EntityHash))
}

Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_ecs/src/entity/hash_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ impl EntityHashSet {
/// Equivalent to [`HashSet::with_hasher(EntityHash)`].
///
/// [`HashSet::with_hasher(EntityHash)`]: HashSet::with_hasher
pub fn new() -> Self {
pub const fn new() -> Self {
Self(HashSet::with_hasher(EntityHash))
}

Expand Down

0 comments on commit 59697f9

Please sign in to comment.