Skip to main content

RunIfFnExt

Trait RunIfFnExt 

Source
pub trait RunIfFnExt<Marker>: IntoSystem<Marker> + Sized {
    // Provided method
    fn run_if_fn<F>(self, cond: F) -> RunIfFnSystem<Self, Marker, F>
       where F: Fn(&World, &Resources) -> bool + 'static { ... }
}
Expand description

Adds .run_if_fn to anything convertible into a System, gating it on a plain closure instead of a RunCondition type — no struct/impl boilerplate needed for a one-off check:

app.add_system(
    SystemStage::Startup,
    setup.run_if_fn(|world, resources| {
        resources.has_resource::<PBR>(world)
            && resources.get_resource::<PBR>(world).cubemap_material_inst != RawAssetHandle::default()
    }),
);

Provided Methods§

Source

fn run_if_fn<F>(self, cond: F) -> RunIfFnSystem<Self, Marker, F>
where F: Fn(&World, &Resources) -> bool + 'static,

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<Marker, T: IntoSystem<Marker>> RunIfFnExt<Marker> for T