use tombstone::{Executor, Query, World}; struct Foo { a: i64, b: f32, } impl Foo { fn new(a: i64, b: f32) -> Self { Self { a, b } } } fn main() { let mut w = World::new(); w.spawn().add(Foo::new(1, 3.6)); w.spawn().add(Foo::new(2, 5.2)); let mut ex = Executor::new(); ex.register(system); let mut sum = 0.; for i in 1..=5 { println!("Iter{i}:"); ex.run_with_state(&mut w, &mut sum); } assert_eq!(sum, (3.6 + 5.2) * 5.); } fn system(mut q: Query<(Foo,), f32>) { for &id in q.ids() { let (foo,) = q.select_mut(id); println!("Entity{id}: ({}, {})", foo.a, foo.b); foo.a += 1; *q.state() += foo.b; } }