Skip to main content

IntoSystem

Trait IntoSystem 

Source
pub trait IntoSystem<Params> {
    type System: System + 'static;

    // Required method
    fn into_system(self, registry: &Registry) -> Self::System;
}
Expand description

Converts a plain function into a System.

The function signature is fn(params...) -> bool — no event parameter. Parameters are resolved from a Registry at conversion time.

§Closures vs named functions

Zero-parameter systems (fn() -> bool) accept closures. For parameterized systems (one or more Param arguments), Rust’s HRTB + GAT inference fails on closures — use named functions. Same limitation as IntoHandler.

§Examples

use nexus_rt::{WorldBuilder, Res, ResMut, IntoSystem, System};

fn reconcile(val: Res<u64>, mut flag: ResMut<bool>) -> bool {
    if *val > 10 {
        *flag = true;
        true
    } else {
        false
    }
}

let mut builder = WorldBuilder::new();
builder.register::<u64>(42);
builder.register::<bool>(false);
let mut world = builder.build();

let mut sys = reconcile.into_system(world.registry());
assert!(sys.run(&mut world));
assert!(*world.resource::<bool>());

§Panics

Panics if any Param resource is not registered in the Registry.

Required Associated Types§

Source

type System: System + 'static

The concrete system type produced.

Required Methods§

Source

fn into_system(self, registry: &Registry) -> Self::System

Convert this function into a system, resolving parameters from the registry.

Implementors§

Source§

impl<F: Send + 'static, P0: Param + 'static> IntoSystem<(P0,)> for F
where for<'a> &'a mut F: FnMut(P0) -> bool + FnMut(P0::Item<'a>) -> bool,

Source§

impl<F: Send + 'static, P0: Param + 'static, P1: Param + 'static> IntoSystem<(P0, P1)> for F
where for<'a> &'a mut F: FnMut(P0, P1) -> bool + FnMut(P0::Item<'a>, P1::Item<'a>) -> bool,

Source§

impl<F: Send + 'static, P0: Param + 'static, P1: Param + 'static, P2: Param + 'static> IntoSystem<(P0, P1, P2)> for F
where for<'a> &'a mut F: FnMut(P0, P1, P2) -> bool + FnMut(P0::Item<'a>, P1::Item<'a>, P2::Item<'a>) -> bool,

Source§

impl<F: Send + 'static, P0: Param + 'static, P1: Param + 'static, P2: Param + 'static, P3: Param + 'static> IntoSystem<(P0, P1, P2, P3)> for F
where for<'a> &'a mut F: FnMut(P0, P1, P2, P3) -> bool + FnMut(P0::Item<'a>, P1::Item<'a>, P2::Item<'a>, P3::Item<'a>) -> bool,

Source§

impl<F: Send + 'static, P0: Param + 'static, P1: Param + 'static, P2: Param + 'static, P3: Param + 'static, P4: Param + 'static> IntoSystem<(P0, P1, P2, P3, P4)> for F
where for<'a> &'a mut F: FnMut(P0, P1, P2, P3, P4) -> bool + FnMut(P0::Item<'a>, P1::Item<'a>, P2::Item<'a>, P3::Item<'a>, P4::Item<'a>) -> bool,

Source§

impl<F: Send + 'static, P0: Param + 'static, P1: Param + 'static, P2: Param + 'static, P3: Param + 'static, P4: Param + 'static, P5: Param + 'static> IntoSystem<(P0, P1, P2, P3, P4, P5)> for F
where for<'a> &'a mut F: FnMut(P0, P1, P2, P3, P4, P5) -> bool + FnMut(P0::Item<'a>, P1::Item<'a>, P2::Item<'a>, P3::Item<'a>, P4::Item<'a>, P5::Item<'a>) -> bool,

Source§

impl<F: Send + 'static, P0: Param + 'static, P1: Param + 'static, P2: Param + 'static, P3: Param + 'static, P4: Param + 'static, P5: Param + 'static, P6: Param + 'static> IntoSystem<(P0, P1, P2, P3, P4, P5, P6)> for F
where for<'a> &'a mut F: FnMut(P0, P1, P2, P3, P4, P5, P6) -> bool + FnMut(P0::Item<'a>, P1::Item<'a>, P2::Item<'a>, P3::Item<'a>, P4::Item<'a>, P5::Item<'a>, P6::Item<'a>) -> bool,

Source§

impl<F: Send + 'static, P0: Param + 'static, P1: Param + 'static, P2: Param + 'static, P3: Param + 'static, P4: Param + 'static, P5: Param + 'static, P6: Param + 'static, P7: Param + 'static> IntoSystem<(P0, P1, P2, P3, P4, P5, P6, P7)> for F
where for<'a> &'a mut F: FnMut(P0, P1, P2, P3, P4, P5, P6, P7) -> bool + FnMut(P0::Item<'a>, P1::Item<'a>, P2::Item<'a>, P3::Item<'a>, P4::Item<'a>, P5::Item<'a>, P6::Item<'a>, P7::Item<'a>) -> bool,

Source§

impl<F: FnMut() -> bool + Send + 'static> IntoSystem<()> for F