I'm trying to instantiate a new Dispatcher
object like so:
fn build_dispatcher() -> Dispatcher {
specs::DispatcherBuilder::new()
.with_thread_local(RenderingSystem)
.build()
}
I get a compiler error stating that this function is missing lifetime specifiers, and expects 2 params. If I provide an argument in the function signature with a reference, then the error goes away and it compiles fine. I'll get warnings because I'm not actually using that reference anywhere in the function itself, but it will compile.
My guess as to why the compiler allows the code with the reference argument is because all references need lifetimes associated with it, the compiler will auto-generate lifetimes if it can infer it, and it is able to successfully infer lifetimes in this case when arguments are provided.
The thing is: I don't need any arguments, and I'm not returning any references. I tried to explicitly add a lifetime parameter, but I have no clue of what to associate it to. My RenderingSystem
struct implements a trait that has a lifetime associated with it, so I'm sure that has something to do with the error:
impl<'a> System<'a> for RenderingSystem {
type SystemData = (
ReadStorage<'a, Position>,
Write<'a, GameState>,
);
fn run(&mut self, data: Self::SystemData) {
/* omitted for brevity */
}
}
Here's the furthest I've gotten so far:
fn build_dispatcher<'a>() -> Dispatcher { // where to use 'a though?
specs::DispatcherBuilder::new()
.with_thread_local(RenderingSystem)
.build()
}