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

Code before:
    /// consider passing them in as inputs.
    ///
    /// If that's not an option, consider [`Commands::register_system`] instead.
    pub fn run_system_cached_with<I, M, S>(&mut self, system: S, input: I::Inner<'static>)
    where
        I: SystemInput<Inner<'static>: Send> + Send + 'static,
        M: 'static,
        S: IntoSystem<I, (), M> + Send + 'static,
    {
        self.queue(command::run_system_cached_with(system, input).handle_error_with(warn));
    }

    /// Sends a global [`Event`] without any targets.
    ///
    /// This will run any [`Observer`] of the given [`Event`] that isn't scoped to specific targets.
    #[track_caller]
    pub fn trigger(&mut self, event: impl Event) {
        self.queue(command::trigger(event));
    }

    /// Sends an [`EntityEvent`] for the given targets.
    ///
    /// This will run any [`Observer`] of the given [`EntityEvent`] watching those targets.
    ///
    /// If the entity that this command targets does not exist when the command is applied,
    /// the command will fail, possibly causing it to panic based on the default error handler set.
    /// To queue this command with a handler, use [`EntityCommands::queue_handled`]
    /// with [`entity_command::trigger(event)`](entity_command::trigger).
    /// [`EntityCommands::queue_silenced`] may also be used to ignore the error completely.
    #[track_caller]
    pub fn trigger_targets(
        &mut self,
        event: impl EntityEvent,
        targets: impl TriggerTargets + Send + Sync + 'static,
    ) {
        self.queue(command::trigger_targets(event, targets));
    }

    /// Spawns an [`Observer`] and returns the [`EntityCommands`] associated
    /// with the entity that stores the observer.
    ///
    /// `observer` can be any system whose first parameter is [`On`].
    ///
    /// **Calling [`observe`](EntityCommands::observe) on the returned
    /// [`EntityCommands`] will observe the observer itself, which you very
    /// likely do not want.**
    ///
    /// # Panics
    ///
    /// Panics if the given system is an exclusive system.
    ///

Review comment (bug):
Maybe link to the default error handler, or the error module docs?
```suggestion
    /// the command will fail, possibly causing it to panic based on the default [error handler](crate::error) set.
```

Code after:
    /// consider passing them in as inputs.
    ///
    /// If that's not an option, consider [`Commands::register_system`] instead.
    pub fn run_system_cached_with<I, M, S>(&mut self, system: S, input: I::Inner<'static>)
    where
        I: SystemInput<Inner<'static>: Send> + Send + 'static,
        M: 'static,
        S: IntoSystem<I, (), M> + Send + 'static,
    {
        self.queue(command::run_system_cached_with(system, input).handle_error_with(warn));
    }

    /// Sends a global [`Event`] without any targets.
    ///
    /// This will run any [`Observer`] of the given [`Event`] that isn't scoped to specific targets.
    ///
    /// If the entity that this command targets does not exist when the command is applied,
    /// the command will fail, possibly causing it to panic based on the default [error handler](crate::error) set.
    ///
    /// To queue this command with a specific handler, use [`EntityCommands::queue_handled`]
    /// with [`entity_command::trigger(event)`](entity_command::trigger).
    /// [`EntityCommands::queue_silenced`] may also be used to ignore the error completely.
    #[track_caller]
    pub fn trigger(&mut self, event: impl Event) {
        self.queue(command::trigger(event));
    }

    /// Sends an [`EntityEvent`] for the given targets.
    ///
    /// This will run any [`Observer`] of the given [`EntityEvent`] watching those targets.
    ///
    /// If the entity that this command targets does not exist when the command is applied,
    /// the command will fail, possibly causing it to panic based on the default [error handler](crate::error) set.
    ///
    /// To queue this command with a specific handler, use [`EntityCommands::queue_handled`]
    /// with [`entity_command::trigger(event)`](entity_command::trigger).
    /// [`EntityCommands::queue_silenced`] may also be used to ignore the error completely.
    #[track_caller]
    pub fn trigger_targets(
        &mut self,
        event: impl EntityEvent,
        targets: impl TriggerTargets + Send + Sync + 'static,
    ) {
        self.queue(command::trigger_targets(event, targets));
    }

    /// Spawns an [`Observer`] and returns the [`EntityCommands`] associated
    /// with the entity that stores the observer.
    ///
    /// `observer` can be any system whose first parameter is [`On`].
    ///