diff --git a/crates/bevy_platform/src/collections/hash_map.rs b/crates/bevy_platform/src/collections/hash_map.rs index 6e771fd2a9583..82f6187faeb45 100644 --- a/crates/bevy_platform/src/collections/hash_map.rs +++ b/crates/bevy_platform/src/collections/hash_map.rs @@ -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 /// @@ -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(&mut self, ks: [&Q; N]) -> [Option<&'_ mut V>; N] + pub fn get_disjoint_mut(&mut self, ks: [&Q; N]) -> [Option<&'_ mut V>; N] where Q: Hash + Equivalent + ?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 /// @@ -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( + pub fn get_disjoint_key_value_mut( &mut self, ks: [&Q; N], ) -> [Option<(&'_ K, &'_ mut V)>; N] where Q: Hash + Equivalent + ?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. @@ -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 /// @@ -1247,7 +1247,7 @@ where reason = "re-exporting unsafe method from Hashbrown requires unsafe code" )] #[inline] - pub unsafe fn get_many_unchecked_mut( + pub unsafe fn get_disjoint_unchecked_mut( &mut self, keys: [&Q; N], ) -> [Option<&'_ mut V>; N] @@ -1255,18 +1255,18 @@ where Q: Hash + Equivalent + ?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 /// @@ -1279,7 +1279,7 @@ where reason = "re-exporting unsafe method from Hashbrown requires unsafe code" )] #[inline] - pub unsafe fn get_many_key_value_unchecked_mut( + pub unsafe fn get_disjoint_key_value_unchecked_mut( &mut self, keys: [&Q; N], ) -> [Option<(&'_ K, &'_ mut V)>; N] @@ -1287,6 +1287,6 @@ where Q: Hash + Equivalent + ?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) } } } diff --git a/release-content/migration-guides/get_many_renamed_to_get_disjoint.md b/release-content/migration-guides/get_many_renamed_to_get_disjoint.md new file mode 100644 index 0000000000000..6af887e7b7004 --- /dev/null +++ b/release-content/migration-guides/get_many_renamed_to_get_disjoint.md @@ -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`