Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions crates/bevy_ecs/src/system/query/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,21 @@ impl<'a, Q: WorldQuery, F: QueryFilter> Query<'a, Q, F> {
.map_err(QueryError::ComponentError)
}

/// Returns an array containing the `Entity`s in this `Query` that had the given `Component`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could use doc links here if you wanted.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I considered this, but there were a few reasons for not doing it:

  • Quickly glancing at other doc comments I didn't see doc links being used, so this function might be an outlier if it used doc links.
  • Links to Entity and Component are already available directly above the documentation in the function definition and you're already on the doc page for Query.

Let me know if I should add them anyway. :)

/// removed in this update.
///
/// `removed::<C>()` only returns entities whose components were removed before the
/// current system started.
///
/// Regular systems do not apply `Commands` until the end of their stage. This means component
/// removals in a regular system won't be accessible through `removed::<C>()` in the same
/// stage, because the removal hasn't actually occurred yet. This can be solved by executing
/// `removed::<C>()` in a later stage. `AppBuilder::add_system_to_stage()` can be used to
/// control at what stage a system runs.
///
/// Thread local systems manipulate the world directly, so removes are applied immediately. This
/// means any system that runs after a thread local system in the same update will pick up
/// removals that happened in the thread local system, regardless of stages.
pub fn removed<C: Component>(&self) -> &[Entity] {
self.world.removed::<C>()
}
Expand Down