pub trait RunSystemLoop: Sized {
// Required method
fn run_system_loop_with<InputSource, T, I, Out, Marker>(
self,
n: usize,
input: InputSource,
system: T,
) -> Vec<Result<Out, RunSystemError>>
where T: IntoSystem<I, Out, Marker>,
I: SystemInput,
InputSource: FnMut() -> <I as SystemInput>::Inner<'static>;
// Provided method
fn run_system_loop<T, Out, Marker>(
self,
n: usize,
system: T,
) -> Vec<Result<Out, RunSystemError>>
where T: IntoSystem<(), Out, Marker> { ... }
}Expand description
A trait similar to bevy_ecs::system::RunSystemOnce, but it runs a system multiple times.
This is useful for testing multiple iterations of a system.
Required Methods§
Sourcefn run_system_loop_with<InputSource, T, I, Out, Marker>(
self,
n: usize,
input: InputSource,
system: T,
) -> Vec<Result<Out, RunSystemError>>where
T: IntoSystem<I, Out, Marker>,
I: SystemInput,
InputSource: FnMut() -> <I as SystemInput>::Inner<'static>,
fn run_system_loop_with<InputSource, T, I, Out, Marker>(
self,
n: usize,
input: InputSource,
system: T,
) -> Vec<Result<Out, RunSystemError>>where
T: IntoSystem<I, Out, Marker>,
I: SystemInput,
InputSource: FnMut() -> <I as SystemInput>::Inner<'static>,
Runs a system n times with the given input source, returning a Vec of the outputs.
§Example
use bevy::prelude::*;
use moonshine_util::diagnostics::RunSystemLoop;
let mut world = World::new();
let mut names = vec!["Alice", "Bob", "Charlie"];
let entities = world.run_system_loop_with(
3,
|| names.pop().unwrap().to_owned(),
|In(name): In<String>, mut commands: Commands| {
commands.spawn(Name::new(name));
});
assert_eq!(entities.len(), 3);
assert_eq!(world.query::<&Name>().iter(&mut world).count(), 3);Provided Methods§
Sourcefn run_system_loop<T, Out, Marker>(
self,
n: usize,
system: T,
) -> Vec<Result<Out, RunSystemError>>where
T: IntoSystem<(), Out, Marker>,
fn run_system_loop<T, Out, Marker>(
self,
n: usize,
system: T,
) -> Vec<Result<Out, RunSystemError>>where
T: IntoSystem<(), Out, Marker>,
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.