Skip to content

Commit 8f93d3e

Browse files
authored
Rename the Allows query filter to Allow (#20541)
This is the bikeshed of all time, but I needed to bring this up before it became a breaking change. In my opinion, `Allow<Disabled>` sounds better than `Allows<Disabled>`. I don't think there's a 1-to-1 comparison in other query keywords yet, but there's the hypothetical `Expect` in [the discussion on #19489](#19489 (comment)), as opposed to `Expects`. `Allows` hasn't been in a release yet, so it's free to change until 0.17 comes out.
1 parent df24cd3 commit 8f93d3e

File tree

10 files changed

+18
-18
lines changed

10 files changed

+18
-18
lines changed

crates/bevy_ecs/src/entity_disabling.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
//! even if they have a `Position` component,
4545
//! but `Query<&Position, With<Disabled>>` or `Query<(&Position, Has<Disabled>)>` will see them.
4646
//!
47-
//! The [`Allows`](crate::query::Allows) query filter is designed to be used with default query filters,
47+
//! The [`Allow`](crate::query::Allow) query filter is designed to be used with default query filters,
4848
//! and ensures that the query will include entities both with and without the specified disabling component.
4949
//!
5050
//! Entities with disabling components are still present in the [`World`] and can be accessed directly,
@@ -161,9 +161,9 @@ pub struct Internal;
161161
/// To be more precise, this checks if the query's [`FilteredAccess`] contains the component,
162162
/// and if it does not, adds a [`Without`](crate::prelude::Without) filter for that component to the query.
163163
///
164-
/// [`Allows`](crate::query::Allows) and [`Has`](crate::prelude::Has) can be used to include entities
164+
/// [`Allow`](crate::query::Allow) and [`Has`](crate::prelude::Has) can be used to include entities
165165
/// with and without the disabling component.
166-
/// [`Allows`](crate::query::Allows) is a [`QueryFilter`](crate::query::QueryFilter) and will simply change
166+
/// [`Allow`](crate::query::Allow) is a [`QueryFilter`](crate::query::QueryFilter) and will simply change
167167
/// the list of shown entities, while [`Has`](crate::prelude::Has) is a [`QueryData`](crate::query::QueryData)
168168
/// and will allow you to see if each entity has the disabling component or not.
169169
///

crates/bevy_ecs/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ pub mod prelude {
8989
},
9090
name::{Name, NameOrEntity},
9191
observer::{Observer, On, Trigger},
92-
query::{Added, Allows, AnyOf, Changed, Has, Or, QueryBuilder, QueryState, With, Without},
92+
query::{Added, Allow, AnyOf, Changed, Has, Or, QueryBuilder, QueryState, With, Without},
9393
related,
9494
relationship::RelationshipTarget,
9595
resource::Resource,

crates/bevy_ecs/src/observer/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -718,7 +718,7 @@ mod tests {
718718
assert_eq!(world.query::<&A>().query(&world).count(), 1);
719719
assert_eq!(
720720
world
721-
.query_filtered::<&Observer, Allows<Internal>>()
721+
.query_filtered::<&Observer, Allow<Internal>>()
722722
.query(&world)
723723
.count(),
724724
2

crates/bevy_ecs/src/query/access.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,10 +263,10 @@ impl Access {
263263
/// This is for components whose values are not accessed (and thus will never cause conflicts),
264264
/// but whose presence in an archetype may affect query results.
265265
///
266-
/// Currently, this is only used for [`Has<T>`] and [`Allows<T>`].
266+
/// Currently, this is only used for [`Has<T>`] and [`Allow<T>`].
267267
///
268268
/// [`Has<T>`]: crate::query::Has
269-
/// [`Allows<T>`]: crate::query::filter::Allows
269+
/// [`Allow<T>`]: crate::query::filter::Allow
270270
pub fn add_archetypal(&mut self, index: ComponentId) {
271271
self.archetypal.grow_and_insert(index.index());
272272
}

crates/bevy_ecs/src/query/filter.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -569,14 +569,14 @@ all_tuples!(
569569
/// Allows a query to contain entities with the component `T`, bypassing [`DefaultQueryFilters`].
570570
///
571571
/// [`DefaultQueryFilters`]: crate::entity_disabling::DefaultQueryFilters
572-
pub struct Allows<T>(PhantomData<T>);
572+
pub struct Allow<T>(PhantomData<T>);
573573

574574
/// SAFETY:
575575
/// `update_component_access` does not add any accesses.
576576
/// This is sound because [`QueryFilter::filter_fetch`] does not access any components.
577577
/// `update_component_access` adds an archetypal filter for `T`.
578578
/// This is sound because it doesn't affect the query
579-
unsafe impl<T: Component> WorldQuery for Allows<T> {
579+
unsafe impl<T: Component> WorldQuery for Allow<T> {
580580
type Fetch<'w> = ();
581581
type State = ComponentId;
582582

@@ -608,13 +608,13 @@ unsafe impl<T: Component> WorldQuery for Allows<T> {
608608
}
609609

610610
fn matches_component_set(_: &ComponentId, _: &impl Fn(ComponentId) -> bool) -> bool {
611-
// Allows<T> always matches
611+
// Allow<T> always matches
612612
true
613613
}
614614
}
615615

616616
// SAFETY: WorldQuery impl performs no access at all
617-
unsafe impl<T: Component> QueryFilter for Allows<T> {
617+
unsafe impl<T: Component> QueryFilter for Allow<T> {
618618
const IS_ARCHETYPAL: bool = true;
619619

620620
#[inline(always)]

crates/bevy_ecs/src/query/state.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2186,8 +2186,8 @@ mod tests {
21862186
let mut query = QueryState::<Has<C>>::new(&mut world);
21872187
assert_eq!(3, query.iter(&world).count());
21882188

2189-
// Allows should bypass the filter entirely
2190-
let mut query = QueryState::<(), Allows<C>>::new(&mut world);
2189+
// Allow should bypass the filter entirely
2190+
let mut query = QueryState::<(), Allow<C>>::new(&mut world);
21912191
assert_eq!(3, query.iter(&world).count());
21922192

21932193
// Other filters should still be respected

crates/bevy_scene/src/dynamic_scene.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ impl DynamicScene {
5656
DynamicSceneBuilder::from_world(world)
5757
.extract_entities(
5858
// we do this instead of a query, in order to completely sidestep default query filters.
59-
// while we could use `Allows<_>`, this wouldn't account for custom disabled components
59+
// while we could use `Allow<_>`, this wouldn't account for custom disabled components
6060
world
6161
.archetypes()
6262
.iter()

crates/bevy_scene/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ mod tests {
122122
entity::Entity,
123123
entity_disabling::Internal,
124124
hierarchy::{ChildOf, Children},
125-
query::Allows,
125+
query::Allow,
126126
reflect::{AppTypeRegistry, ReflectComponent},
127127
world::World,
128128
};
@@ -307,7 +307,7 @@ mod tests {
307307
.insert_resource(world.resource::<AppTypeRegistry>().clone());
308308
let entities: Vec<Entity> = scene
309309
.world
310-
.query_filtered::<Entity, Allows<Internal>>()
310+
.query_filtered::<Entity, Allow<Internal>>()
311311
.iter(&scene.world)
312312
.collect();
313313
DynamicSceneBuilder::from_world(&scene.world)

release-content/migration-guides/deprecate_iter_entities.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ pull_requests: [20260]
66
In Bevy 0.17.0 we deprecate `world.iter_entities()` and `world.iter_entities_mut()`.
77
Use `world.query::<EntityMut>().iter(&world)` and `world.query::<EntityRef>().iter(&mut world)` instead.
88

9-
This may not return every single entity, because of [default filter queries](https://docs.rs/bevy/latest/bevy/ecs/entity_disabling/index.html). If you really intend to query disabled entities too, consider removing the `DefaultQueryFilters` resource from the world before querying the elements. You can also add an `Allows<Component>` filter to allow a specific disabled `Component`, to show up in the query.
9+
This may not return every single entity, because of [default filter queries](https://docs.rs/bevy/latest/bevy/ecs/entity_disabling/index.html). If you really intend to query disabled entities too, consider removing the `DefaultQueryFilters` resource from the world before querying the elements. You can also add an `Allow<Component>` filter to allow a specific disabled `Component`, to show up in the query.

release-content/migration-guides/internal_entities.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ Bevy 0.17 introduces internal entities. Entities tagged by the `Internal` compon
77

88
Currently, both [`Observer`s](https://docs.rs/bevy/latest/bevy/ecs/observer/struct.Observer.html) and systems that are registered through [`World::register_system`](https://docs.rs/bevy/latest/bevy/prelude/struct.World.html#method.register_system) are considered internal entities.
99

10-
If you queried them before, add the `Allows<Internal>` filter to the query to bypass the default filter.
10+
If you queried them before, add the `Allow<Internal>` filter to the query to bypass the default filter.

0 commit comments

Comments
 (0)