Function bevy::ecs::prelude::ignore

pub fn ignore<T>(_: In<T>)
Expand description

System adapter that ignores the output of the previous system in a pipe. This is useful for fallible systems that should simply return early in case of an Err/None.

Examples

Returning early

use bevy_ecs::prelude::*;

// Marker component for an enemy entity.
#[derive(Component)]
struct Monster;

// Building a new schedule/app...
    .add_system(
        // If the system fails, just move on and try again next frame.
        fallible_system.pipe(system_adapter::ignore)
    )
    // ...

// A system which may return early. It's more convenient to use the `?` operator for this.
fn fallible_system(
    q: Query<Entity, With<Monster>>
) -> Option<()> {
    let monster_id = q.iter().next()?;
    println!("Monster entity is {monster_id:?}");
    Some(())
}