Skip to content

Commit

Permalink
Rename get_mut_n for consistency with proposed std slice method
Browse files Browse the repository at this point in the history
  • Loading branch information
Ralith committed Dec 23, 2023
1 parent 60546b0 commit 77b5407
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# Unreleased

# Changed
- Renamed `{View, PreparedView}::get_mut_n` to `get_many_mut` for consistency with the proposed std
slice method

# 0.10.4

### Added
Expand Down
24 changes: 21 additions & 3 deletions src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1436,7 +1436,10 @@ impl<'q, Q: Query> View<'q, Q> {
/// assert_eq!(*b.unwrap(), 2);
/// assert_eq!(*c.unwrap(), 3);
/// ```
pub fn get_mut_n<const N: usize>(&mut self, entities: [Entity; N]) -> [Option<Q::Item<'_>>; N] {
pub fn get_many_mut<const N: usize>(
&mut self,
entities: [Entity; N],
) -> [Option<Q::Item<'_>>; N] {
assert_distinct(&entities);

let mut items = [(); N].map(|()| None);
Expand All @@ -1450,6 +1453,12 @@ impl<'q, Q: Query> View<'q, Q> {
items
}

#[doc(hidden)]
#[deprecated(since = "0.10.5", note = "renamed to `get_many_mut`")]
pub fn get_mut_n<const N: usize>(&mut self, entities: [Entity; N]) -> [Option<Q::Item<'_>>; N] {
self.get_many_mut(entities)
}

/// Iterate over all entities satisfying `Q`
///
/// Equivalent to [`QueryBorrow::iter`].
Expand Down Expand Up @@ -1599,8 +1608,11 @@ impl<'q, Q: Query> PreparedView<'q, Q> {

/// Like `get_mut`, but allows checked simultaneous access to multiple entities
///
/// See [`View::get_mut_n`] for details.
pub fn get_mut_n<const N: usize>(&mut self, entities: [Entity; N]) -> [Option<Q::Item<'_>>; N] {
/// See [`View::get_many_mut`] for details.
pub fn get_many_mut<const N: usize>(
&mut self,
entities: [Entity; N],
) -> [Option<Q::Item<'_>>; N] {
assert_distinct(&entities);

let mut items = [(); N].map(|()| None);
Expand All @@ -1614,6 +1626,12 @@ impl<'q, Q: Query> PreparedView<'q, Q> {
items
}

#[doc(hidden)]
#[deprecated(since = "0.10.5", note = "renamed to `get_many_mut`")]
pub fn get_mut_n<const N: usize>(&mut self, entities: [Entity; N]) -> [Option<Q::Item<'_>>; N] {
self.get_many_mut(entities)
}

/// Iterate over all entities satisfying `Q`
///
/// Equivalent to [`PreparedQueryBorrow::iter`].
Expand Down

0 comments on commit 77b5407

Please sign in to comment.