So I'm following this tutorial to build a rogue-like and I've decided to start using the specs dispatcher to make registering and executing systems a bit easier.
To do that I've added a Dispatcher
to my State
struct:
use rltk::{GameState, Rltk};
use specs::world::World;
use specs::Dispatcher;
pub struct State<'a, 'b> { // <-- Added new lifetime params here for dispacher
pub ecs: World,
pub dsp: Dispatcher<'a, 'b>,
}
But it's when I try to implement the GameSate
trait for it I run into issues:
impl<'a, 'b> GameState for State<'a, 'b> {
fn tick(&mut self, ctx: &mut Rltk) {
ctx.cls();
self.dsp.dispatch(&mut self.ecs);
self.ecs.maintain();
}
}
I get these errors:
error[E0478]: lifetime bound not satisfied
--> src/sys/state.rs:96:14
|
96 | impl<'a, 'b> GameState for State<'a, 'b> {
| ^^^^^^^^^
|
note: lifetime parameter instantiated with the lifetime `'a` as defined on the impl at 96:6
--> src/sys/state.rs:96:6
|
96 | impl<'a, 'b> GameState for State<'a, 'b> {
| ^^
= note: but lifetime parameter must outlive the static lifetime
error[E0478]: lifetime bound not satisfied
--> src/sys/state.rs:96:14
|
96 | impl<'a, 'b> GameState for State<'a, 'b> {
| ^^^^^^^^^
|
note: lifetime parameter instantiated with the lifetime `'b` as defined on the impl at 96:10
--> src/sys/state.rs:96:10
|
96 | impl<'a, 'b> GameState for State<'a, 'b> {
| ^^
= note: but lifetime parameter must outlive the static lifetime
It wants the lifetimes 'a, 'b
to outlive 'static
, which sounds impossible as I'm sure that 'static
is the whole program's lifetime.
How do I resolve this?