Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update docs of set_if_neq and replace_if_neq #12919

Merged
merged 4 commits into from
Apr 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 12 additions & 0 deletions crates/bevy_ecs/src/change_detection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,12 @@ pub trait DetectChangesMut: DetectChanges {
/// This is useful to ensure change detection is only triggered when the underlying value
/// changes, instead of every time it is mutably accessed.
///
/// If you're dealing with non-trivial structs which have multiple fields of non-trivial size,
/// then consider applying a `map_unchanged` beforehand to allow changing only the relevant
/// field and prevent unnecessary copying and cloning.
/// See the docs of [`Mut::map_unchanged`], [`MutUntyped::map_unchanged`],
/// [`ResMut::map_unchanged`] or [`NonSendMut::map_unchanged`] for an example
///
/// If you need the previous value, use [`replace_if_neq`](DetectChangesMut::replace_if_neq).
///
/// # Examples
Expand Down Expand Up @@ -181,6 +187,12 @@ pub trait DetectChangesMut: DetectChanges {
/// This is useful to ensure change detection is only triggered when the underlying value
/// changes, instead of every time it is mutably accessed.
///
/// If you're dealing with non-trivial structs which have multiple fields of non-trivial size,
/// then consider applying a [`map_unchanged`](Mut::map_unchanged) beforehand to allow
/// changing only the relevant field and prevent unnecessary copying and cloning.
/// See the docs of [`Mut::map_unchanged`], [`MutUntyped::map_unchanged`],
/// [`ResMut::map_unchanged`] or [`NonSendMut::map_unchanged`] for an example
///
/// If you don't need the previous value, use [`set_if_neq`](DetectChangesMut::set_if_neq).
///
/// # Examples
Expand Down