forked from feather-rs/feather
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsystems.rs
More file actions
42 lines (34 loc) · 742 Bytes
/
Copy pathsystems.rs
File metadata and controls
42 lines (34 loc) · 742 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#![allow(clippy::unnecessary_wraps)]
use feather_ecs::{Ecs, HasEcs, SysResult, SystemExecutor};
struct Input {
x: i32,
ecs: Ecs,
}
impl HasEcs for Input {
fn ecs(&self) -> &Ecs {
&self.ecs
}
fn ecs_mut(&mut self) -> &mut Ecs {
&mut self.ecs
}
}
fn system1(input: &mut Input) -> SysResult {
input.x += 10;
Ok(())
}
fn system2(input: &mut Input) -> SysResult {
input.x *= 10;
Ok(())
}
#[test]
fn systems_are_executed_in_order() {
let mut executor = SystemExecutor::new();
executor.add_system(system1);
executor.add_system(system2);
let mut input = Input {
x: 1,
ecs: Ecs::new(),
};
executor.run(&mut input);
assert_eq!(input.x, 110);
}