Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions crates/bevy_platform/src/collections/hash_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1032,7 +1032,7 @@ where

/// Attempts to get mutable references to `N` values in the map at once.
///
/// Refer to [`get_many_mut`](hb::HashMap::get_many_mut) for further details.
/// Refer to [`get_disjoint_mut`](hb::HashMap::get_disjoint_mut) for further details.
///
/// # Examples
///
Expand All @@ -1044,22 +1044,22 @@ where
/// map.insert("bar", 1);
/// map.insert("baz", 2);
///
/// let result = map.get_many_mut(["foo", "bar"]);
/// let result = map.get_disjoint_mut(["foo", "bar"]);
///
/// assert_eq!(result, [Some(&mut 0), Some(&mut 1)]);
/// ```
#[inline]
pub fn get_many_mut<Q, const N: usize>(&mut self, ks: [&Q; N]) -> [Option<&'_ mut V>; N]
pub fn get_disjoint_mut<Q, const N: usize>(&mut self, ks: [&Q; N]) -> [Option<&'_ mut V>; N]
where
Q: Hash + Equivalent<K> + ?Sized,
{
self.0.get_many_mut(ks)
self.0.get_disjoint_mut(ks)
}

/// Attempts to get mutable references to `N` values in the map at once, with immutable
/// references to the corresponding keys.
///
/// Refer to [`get_many_key_value_mut`](hb::HashMap::get_many_key_value_mut) for further details.
/// Refer to [`get_disjoint_key_value_mut`](hb::HashMap::get_disjoint_key_value_mut) for further details.
///
/// # Examples
///
Expand All @@ -1071,19 +1071,19 @@ where
/// map.insert("bar", 1);
/// map.insert("baz", 2);
///
/// let result = map.get_many_key_value_mut(["foo", "bar"]);
/// let result = map.get_disjoint_key_value_mut(["foo", "bar"]);
///
/// assert_eq!(result, [Some((&"foo", &mut 0)), Some((&"bar", &mut 1))]);
/// ```
#[inline]
pub fn get_many_key_value_mut<Q, const N: usize>(
pub fn get_disjoint_key_value_mut<Q, const N: usize>(
&mut self,
ks: [&Q; N],
) -> [Option<(&'_ K, &'_ mut V)>; N]
where
Q: Hash + Equivalent<K> + ?Sized,
{
self.0.get_many_key_value_mut(ks)
self.0.get_disjoint_key_value_mut(ks)
}

/// Inserts a key-value pair into the map.
Expand Down Expand Up @@ -1229,12 +1229,12 @@ where
/// Attempts to get mutable references to `N` values in the map at once, without validating that
/// the values are unique.
///
/// Refer to [`get_many_unchecked_mut`](hb::HashMap::get_many_unchecked_mut) for further details.
/// Refer to [`get_disjoint_unchecked_mut`](hb::HashMap::get_disjoint_unchecked_mut) for further details.
///
/// Returns an array of length `N` with the results of each query. `None` will be used if
/// the key is missing.
///
/// For a safe alternative see [`get_many_mut`](`HashMap::get_many_mut`).
/// For a safe alternative see [`get_disjoint_mut`](`HashMap::get_disjoint_mut`).
///
/// # Safety
///
Expand All @@ -1247,26 +1247,26 @@ where
reason = "re-exporting unsafe method from Hashbrown requires unsafe code"
)]
#[inline]
pub unsafe fn get_many_unchecked_mut<Q, const N: usize>(
pub unsafe fn get_disjoint_unchecked_mut<Q, const N: usize>(
&mut self,
keys: [&Q; N],
) -> [Option<&'_ mut V>; N]
where
Q: Hash + Equivalent<K> + ?Sized,
{
// SAFETY: safety contract is ensured by the caller.
unsafe { self.0.get_many_unchecked_mut(keys) }
unsafe { self.0.get_disjoint_unchecked_mut(keys) }
}

/// Attempts to get mutable references to `N` values in the map at once, with immutable
/// references to the corresponding keys, without validating that the values are unique.
///
/// Refer to [`get_many_key_value_unchecked_mut`](hb::HashMap::get_many_key_value_unchecked_mut) for further details.
/// Refer to [`get_disjoint_key_value_unchecked_mut`](hb::HashMap::get_disjoint_key_value_unchecked_mut) for further details.
///
/// Returns an array of length `N` with the results of each query. `None` will be returned if
/// any of the keys are missing.
///
/// For a safe alternative see [`get_many_key_value_mut`](`HashMap::get_many_key_value_mut`).
/// For a safe alternative see [`get_disjoint_key_value_mut`](`HashMap::get_disjoint_key_value_mut`).
///
/// # Safety
///
Expand All @@ -1279,14 +1279,14 @@ where
reason = "re-exporting unsafe method from Hashbrown requires unsafe code"
)]
#[inline]
pub unsafe fn get_many_key_value_unchecked_mut<Q, const N: usize>(
pub unsafe fn get_disjoint_key_value_unchecked_mut<Q, const N: usize>(
&mut self,
keys: [&Q; N],
) -> [Option<(&'_ K, &'_ mut V)>; N]
where
Q: Hash + Equivalent<K> + ?Sized,
{
// SAFETY: safety contract is ensured by the caller.
unsafe { self.0.get_many_key_value_unchecked_mut(keys) }
unsafe { self.0.get_disjoint_key_value_unchecked_mut(keys) }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
title: Renamed `bevy_platform::HashMap::get_many_*` to `bevy_platform::HashMap::get_disjoint_*`
pull_requests: [21898]
---

Matching both [`hashbrown`](https://github.com/rust-lang/hashbrown/pull/648) and the `std` library,
we've renamed all the `get_many_*` methods on `bevy_platform::HashMap` to `get_disjoint_*`. So
rename:

- `get_many_mut` -> `get_disjoint_mut`
- `get_many_unchecked_mut` -> `get_disjoint_unchecked_mut`
- `get_many_key_value_mut` -> `get_disjoint_key_value_mut`
- `get_many_key_value_unchecked_mut` -> `get_disjoint_key_value_unchecked_mut`