Skip to content

Commit 5bc1d68

Browse files
Deprecated Query::many and many_mut (#18183)
# Objective Alternative to and closes #18120. Sibling to #18082, see that PR for broader reasoning. Folks weren't sold on the name `many` (get_many is clearer, and this is rare), and that PR is much more complex. ## Solution - Simply deprecate `Query::many` and `Query::many_mut` - Clean up internal usages Mentions of this in the docs can wait until it's fully removed in the 0.17 cycle IMO: it's much easier to catch the problems when doing that. ## Testing CI! ## Migration Guide `Query::many` and `Query::many_mut` have been deprecated to reduce panics and API duplication. Use `Query::get_many` and `Query::get_many_mut` instead, and handle the `Result`. --------- Co-authored-by: Chris Russell <[email protected]>
1 parent 664000f commit 5bc1d68

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

crates/bevy_ecs/src/query/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -777,7 +777,6 @@ mod tests {
777777
let _: Option<&Foo> = q.get(e).ok();
778778
let _: Option<[&Foo; 1]> = q.get_many([e]).ok();
779779
let _: Option<&Foo> = q.single().ok();
780-
let _: [&Foo; 1] = q.many([e]);
781780
let _: &Foo = q.single().unwrap();
782781
}
783782

crates/bevy_ecs/src/system/query.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1377,6 +1377,7 @@ impl<'w, 's, D: QueryData, F: QueryFilter> Query<'w, 's, D, F> {
13771377
/// - [`get_many`](Self::get_many) for the non-panicking version.
13781378
#[inline]
13791379
#[track_caller]
1380+
#[deprecated(note = "Use `get_many` instead and handle the Result.")]
13801381
pub fn many<const N: usize>(&self, entities: [Entity; N]) -> [ROQueryItem<'_, D>; N] {
13811382
match self.get_many(entities) {
13821383
Ok(items) => items,
@@ -1682,6 +1683,7 @@ impl<'w, 's, D: QueryData, F: QueryFilter> Query<'w, 's, D, F> {
16821683
/// - [`many`](Self::many) to get read-only query items.
16831684
#[inline]
16841685
#[track_caller]
1686+
#[deprecated(note = "Use `get_many_mut` instead and handle the Result.")]
16851687
pub fn many_mut<const N: usize>(&mut self, entities: [Entity; N]) -> [D::Item<'_>; N] {
16861688
match self.get_many_mut(entities) {
16871689
Ok(items) => items,

0 commit comments

Comments
 (0)