Skip to content

Commit

Permalink
Improve documentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
Themayu committed May 14, 2024
1 parent d88e03b commit c3e17f1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion crates/bevy_ecs/src/change_detection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,7 @@ impl_debug!(Ref<'w, T>,);
/// Unique mutable borrow of an entity's component or of a resource.
///
/// This can be used in queries to opt into change detection on both their mutable and immutable forms, as opposed to
/// `&mut T`, which only opts into change detection on their mutable forms:
/// `&mut T`, which only provides access to change detection while in its mutable form:
///
/// ```rust
/// # use bevy_ecs::prelude::*;
Expand Down
7 changes: 3 additions & 4 deletions crates/bevy_ecs/src/query/fetch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1378,10 +1378,9 @@ unsafe impl<'__w, T: Component> QueryData for &'__w mut T {
type ReadOnly = &'__w T;
}

/// Mirroring implementation for `&mut T` -> `&T` in a query, by providing `Mut<T>` -> `Ref<T>` for change detection in a query's read-only type.
///
/// Where using `&mut T` in a query will provide `Mut<T>` in the mutable query type and `&T` in the read-only query type,
/// using `Mut<T>` directly in the query will provide `Mut<T>` in the mutable query type and `Ref<T>` in the read-only query type.
/// When `Mut<T>` is used in a query, it will be converted to `Ref<T>` when transformed into its read-only form, providing access to change detection methods.
///
/// By contrast `&mut T` will result in a `Mut<T>` item in mutable form to record mutations, but result in a bare `&T` in read-only form.
///
/// SAFETY:
/// `fetch` accesses a single component mutably.
Expand Down

0 comments on commit c3e17f1

Please sign in to comment.