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.
This commit is contained in:
Joona Aalto 2025-01-30 19:40:06 +02:00 committed by GitHub
parent 7d68ac029e
commit 59697f9ccc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 2 additions and 2 deletions

View File

@ -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))
}

View File

@ -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))
}