Skip to content
Open
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions crates/bevy_ecs/src/component/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ use core::{fmt::Debug, marker::PhantomData, ops::Deref};
/// Note that cycles in the "component require tree" will result in stack overflows when attempting to
/// insert a component.
///
/// This "multiple inheritance" pattern does mean that it is possible to have duplicate requires for a given type
/// This "multiple inheritance" pattern does mean that it is possible to have duplicate `require`s for a given type
/// at different levels of the inheritance tree:
///
/// ```
Expand Down Expand Up @@ -321,7 +321,7 @@ use core::{fmt::Debug, marker::PhantomData, ops::Deref};
/// assert_eq!(&C(2), world.entity(id).get::<C>().unwrap());
/// ```
///
/// Similar rules as before apply to duplicate requires fer a given type at different levels
/// Similar rules as before apply to duplicate `require`s for a given type at different levels
/// of the inheritance tree. `A` requiring `C` directly would take precedence over indirectly
/// requiring it through `A` requiring `B` and `B` requiring `C`.
///
Expand Down
17 changes: 16 additions & 1 deletion crates/bevy_ecs/src/system/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2822,16 +2822,31 @@ impl<'w, 'q, Q: SingleEntityQueryData, F: QueryFilter> From<&'q mut Query<'w, '_
/// ```
/// # use bevy_ecs::prelude::*;
/// #[derive(Component)]
/// struct Hiding;
///
/// #[derive(Component)]
/// struct Boss {
/// health: f32
/// };
///
/// fn hurt_boss(mut boss: Single<&mut Boss>) {
/// #[derive(Component)]
/// struct EnemySize {
/// height: f32
/// };
///
/// fn hurt_boss(mut boss: Single<&mut Boss, Without<Hiding>>) {
/// boss.health -= 4.0;
/// }
///
/// fn hurt_and_shrink_boss(mut boss_and_size: Single<(&mut Boss, &mut EnemySize)>) {
/// let (mut boss, mut size) = boss_and_size.into_inner();
/// boss.health -= 4.0;
/// size.height *= 0.5;
/// }
/// ```
/// Note that because [`Single`] implements [`Deref`] and [`DerefMut`], methods and fields like `health` can be accessed directly.
/// You can also access the underlying data manually, by calling `.deref`/`.deref_mut`, or by using the `*` operator.
/// When mutable elements appear in [`Single`], use `.into_inner` to extract the tuple elements to mutate them.
pub struct Single<'w, 's, D: IterQueryData, F: QueryFilter = ()> {
pub(crate) item: D::Item<'w, 's>,
pub(crate) _filter: PhantomData<F>,
Expand Down
Loading