From 59697f9cccc5d9422ccda26300263579ae67539e Mon Sep 17 00:00:00 2001 From: Joona Aalto Date: Thu, 30 Jan 2025 19:40:06 +0200 Subject: [PATCH] Make `EntityHashMap::new` and `EntityHashSet::new` const (#17615) # 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. --- crates/bevy_ecs/src/entity/hash_map.rs | 2 +- crates/bevy_ecs/src/entity/hash_set.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/bevy_ecs/src/entity/hash_map.rs b/crates/bevy_ecs/src/entity/hash_map.rs index 627f30cbe79ea..3d054be9ce718 100644 --- a/crates/bevy_ecs/src/entity/hash_map.rs +++ b/crates/bevy_ecs/src/entity/hash_map.rs @@ -26,7 +26,7 @@ impl EntityHashMap { /// 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)) } diff --git a/crates/bevy_ecs/src/entity/hash_set.rs b/crates/bevy_ecs/src/entity/hash_set.rs index 41fdb33fa7ca1..ba034df917633 100644 --- a/crates/bevy_ecs/src/entity/hash_set.rs +++ b/crates/bevy_ecs/src/entity/hash_set.rs @@ -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)) }