Skip to content

Commit e1de883

Browse files
authored
Replace get_many_* with get_disjoint_*. (#21898)
# Objective - Fixes CI after rust-lang/hashbrown#648. ## Solution - Match the naming in hashbrown, and in std!
1 parent 7ad5fb7 commit e1de883

File tree

2 files changed

+29
-16
lines changed

2 files changed

+29
-16
lines changed

crates/bevy_platform/src/collections/hash_map.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1032,7 +1032,7 @@ where
10321032

10331033
/// Attempts to get mutable references to `N` values in the map at once.
10341034
///
1035-
/// Refer to [`get_many_mut`](hb::HashMap::get_many_mut) for further details.
1035+
/// Refer to [`get_disjoint_mut`](hb::HashMap::get_disjoint_mut) for further details.
10361036
///
10371037
/// # Examples
10381038
///
@@ -1044,22 +1044,22 @@ where
10441044
/// map.insert("bar", 1);
10451045
/// map.insert("baz", 2);
10461046
///
1047-
/// let result = map.get_many_mut(["foo", "bar"]);
1047+
/// let result = map.get_disjoint_mut(["foo", "bar"]);
10481048
///
10491049
/// assert_eq!(result, [Some(&mut 0), Some(&mut 1)]);
10501050
/// ```
10511051
#[inline]
1052-
pub fn get_many_mut<Q, const N: usize>(&mut self, ks: [&Q; N]) -> [Option<&'_ mut V>; N]
1052+
pub fn get_disjoint_mut<Q, const N: usize>(&mut self, ks: [&Q; N]) -> [Option<&'_ mut V>; N]
10531053
where
10541054
Q: Hash + Equivalent<K> + ?Sized,
10551055
{
1056-
self.0.get_many_mut(ks)
1056+
self.0.get_disjoint_mut(ks)
10571057
}
10581058

10591059
/// Attempts to get mutable references to `N` values in the map at once, with immutable
10601060
/// references to the corresponding keys.
10611061
///
1062-
/// Refer to [`get_many_key_value_mut`](hb::HashMap::get_many_key_value_mut) for further details.
1062+
/// Refer to [`get_disjoint_key_value_mut`](hb::HashMap::get_disjoint_key_value_mut) for further details.
10631063
///
10641064
/// # Examples
10651065
///
@@ -1071,19 +1071,19 @@ where
10711071
/// map.insert("bar", 1);
10721072
/// map.insert("baz", 2);
10731073
///
1074-
/// let result = map.get_many_key_value_mut(["foo", "bar"]);
1074+
/// let result = map.get_disjoint_key_value_mut(["foo", "bar"]);
10751075
///
10761076
/// assert_eq!(result, [Some((&"foo", &mut 0)), Some((&"bar", &mut 1))]);
10771077
/// ```
10781078
#[inline]
1079-
pub fn get_many_key_value_mut<Q, const N: usize>(
1079+
pub fn get_disjoint_key_value_mut<Q, const N: usize>(
10801080
&mut self,
10811081
ks: [&Q; N],
10821082
) -> [Option<(&'_ K, &'_ mut V)>; N]
10831083
where
10841084
Q: Hash + Equivalent<K> + ?Sized,
10851085
{
1086-
self.0.get_many_key_value_mut(ks)
1086+
self.0.get_disjoint_key_value_mut(ks)
10871087
}
10881088

10891089
/// Inserts a key-value pair into the map.
@@ -1229,12 +1229,12 @@ where
12291229
/// Attempts to get mutable references to `N` values in the map at once, without validating that
12301230
/// the values are unique.
12311231
///
1232-
/// Refer to [`get_many_unchecked_mut`](hb::HashMap::get_many_unchecked_mut) for further details.
1232+
/// Refer to [`get_disjoint_unchecked_mut`](hb::HashMap::get_disjoint_unchecked_mut) for further details.
12331233
///
12341234
/// Returns an array of length `N` with the results of each query. `None` will be used if
12351235
/// the key is missing.
12361236
///
1237-
/// For a safe alternative see [`get_many_mut`](`HashMap::get_many_mut`).
1237+
/// For a safe alternative see [`get_disjoint_mut`](`HashMap::get_disjoint_mut`).
12381238
///
12391239
/// # Safety
12401240
///
@@ -1247,26 +1247,26 @@ where
12471247
reason = "re-exporting unsafe method from Hashbrown requires unsafe code"
12481248
)]
12491249
#[inline]
1250-
pub unsafe fn get_many_unchecked_mut<Q, const N: usize>(
1250+
pub unsafe fn get_disjoint_unchecked_mut<Q, const N: usize>(
12511251
&mut self,
12521252
keys: [&Q; N],
12531253
) -> [Option<&'_ mut V>; N]
12541254
where
12551255
Q: Hash + Equivalent<K> + ?Sized,
12561256
{
12571257
// SAFETY: safety contract is ensured by the caller.
1258-
unsafe { self.0.get_many_unchecked_mut(keys) }
1258+
unsafe { self.0.get_disjoint_unchecked_mut(keys) }
12591259
}
12601260

12611261
/// Attempts to get mutable references to `N` values in the map at once, with immutable
12621262
/// references to the corresponding keys, without validating that the values are unique.
12631263
///
1264-
/// Refer to [`get_many_key_value_unchecked_mut`](hb::HashMap::get_many_key_value_unchecked_mut) for further details.
1264+
/// Refer to [`get_disjoint_key_value_unchecked_mut`](hb::HashMap::get_disjoint_key_value_unchecked_mut) for further details.
12651265
///
12661266
/// Returns an array of length `N` with the results of each query. `None` will be returned if
12671267
/// any of the keys are missing.
12681268
///
1269-
/// For a safe alternative see [`get_many_key_value_mut`](`HashMap::get_many_key_value_mut`).
1269+
/// For a safe alternative see [`get_disjoint_key_value_mut`](`HashMap::get_disjoint_key_value_mut`).
12701270
///
12711271
/// # Safety
12721272
///
@@ -1279,14 +1279,14 @@ where
12791279
reason = "re-exporting unsafe method from Hashbrown requires unsafe code"
12801280
)]
12811281
#[inline]
1282-
pub unsafe fn get_many_key_value_unchecked_mut<Q, const N: usize>(
1282+
pub unsafe fn get_disjoint_key_value_unchecked_mut<Q, const N: usize>(
12831283
&mut self,
12841284
keys: [&Q; N],
12851285
) -> [Option<(&'_ K, &'_ mut V)>; N]
12861286
where
12871287
Q: Hash + Equivalent<K> + ?Sized,
12881288
{
12891289
// SAFETY: safety contract is ensured by the caller.
1290-
unsafe { self.0.get_many_key_value_unchecked_mut(keys) }
1290+
unsafe { self.0.get_disjoint_key_value_unchecked_mut(keys) }
12911291
}
12921292
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
title: Renamed `bevy_platform::HashMap::get_many_*` to `bevy_platform::HashMap::get_disjoint_*`
3+
pull_requests: [21898]
4+
---
5+
6+
Matching both [`hashbrown`](https://github.com/rust-lang/hashbrown/pull/648) and the `std` library,
7+
we've renamed all the `get_many_*` methods on `bevy_platform::HashMap` to `get_disjoint_*`. So
8+
rename:
9+
10+
- `get_many_mut` -> `get_disjoint_mut`
11+
- `get_many_unchecked_mut` -> `get_disjoint_unchecked_mut`
12+
- `get_many_key_value_mut` -> `get_disjoint_key_value_mut`
13+
- `get_many_key_value_unchecked_mut` -> `get_disjoint_key_value_unchecked_mut`

0 commit comments

Comments
 (0)