Repository: bevyengine/bevy
File: crates/bevy_ecs/src/system/system_param.rs (Rust)

Code before:
/// // Counter is initialized to u32's default value of 0, and increases to 1 on first run.
/// assert_eq!(counter_system.run((), world).unwrap(), 1);
/// // Counter gets the same value and increases to 2 on its second call.
/// assert_eq!(counter_system.run((), world).unwrap(), 2);
/// ```
///
/// A simple way to set a different default value for a local is by wrapping the value with an Option.
///
/// ```
/// # use bevy_ecs::prelude::*;
/// # let world = &mut World::default();
/// fn counter_from_10(mut count: Local<Option<u32>>) -> u32 {
///     let count = count.get_or_insert(10);
///     *count += 1;
///     *count
/// }
/// let mut counter_system = IntoSystem::into_system(counter_from_10);
/// counter_system.initialize(world);
///
/// // Counter is initialized at 10, and increases to 11 on first run.
/// assert_eq!(counter_system.run((), world).unwrap(), 11);
/// // Counter is only increased by 1 on subsequent runs.
/// assert_eq!(counter_system.run((), world).unwrap(), 12);
/// ```
///
/// A system having multiple locals with the same type are distinct values.
///
/// ```
/// # use bevy_ecs::prelude::*;
/// # let world = &mut World::default();
/// fn double_counter(mut count: Local<u32>, mut double_count: Local<u32>) -> (u32, u32) {
///     *count += 1;
///     *double_count += 2;
///     (*count, *double_count)
/// }
/// let mut counter_system = IntoSystem::into_system(double_counter);
/// counter_system.initialize(world);
///
/// assert_eq!(counter_system.run((), world).unwrap(), (1, 2));
/// // Counter is only increased by 1 on subsequent runs.
/// assert_eq!(counter_system.run((), world).unwrap(), (2, 4));
/// ```
///
/// This example shows that two systems using the same type for their own local get different locals.
///
/// ```
/// # use bevy_ecs::prelude::*;
/// # let world = &mut World::default();
/// fn write_to_local(mut local: Local<usize>) {
///     *local = 42;
/// }

Review comment (suggestion):
```suggestion
/// A system can have multiple `Local` values with the same type, each with distinct values.
```

Code after:
/// // Counter gets the same value and increases to 2 on its second call.
/// assert_eq!(counter_system.run((), world).unwrap(), 2);
/// ```
///
/// A simple way to set a different default value for a local is by wrapping the value with an Option.
///
/// ```
/// # use bevy_ecs::prelude::*;
/// # let world = &mut World::default();
/// fn counter_from_10(mut count: Local<Option<u32>>) -> u32 {
///     let count = count.get_or_insert(10);
///     *count += 1;
///     *count
/// }
/// let mut counter_system = IntoSystem::into_system(counter_from_10);
/// counter_system.initialize(world);
///
/// // Counter is initialized at 10, and increases to 11 on first run.
/// assert_eq!(counter_system.run((), world).unwrap(), 11);
/// // Counter is only increased by 1 on subsequent runs.
/// assert_eq!(counter_system.run((), world).unwrap(), 12);
/// ```
///
/// A system can have multiple `Local` values with the same type, each with distinct values.
///
/// ```
/// # use bevy_ecs::prelude::*;
/// # let world = &mut World::default();
/// fn double_counter(mut count: Local<u32>, mut double_count: Local<u32>) -> (u32, u32) {
///     *count += 1;
///     *double_count += 2;
///     (*count, *double_count)
/// }
/// let mut counter_system = IntoSystem::into_system(double_counter);
/// counter_system.initialize(world);
///
/// assert_eq!(counter_system.run((), world).unwrap(), (1, 2));
/// assert_eq!(counter_system.run((), world).unwrap(), (2, 4));
/// ```
///
/// This example shows that two systems using the same type for their own `Local` get distinct locals.
///
/// ```
/// # use bevy_ecs::prelude::*;
/// # let world = &mut World::default();
/// fn write_to_local(mut local: Local<usize>) {
///     *local = 42;
/// }
/// fn read_from_local(local: Local<usize>) -> usize {
///     *local
/// }