I'm trying to do something similar to this rustnomicon chapter except with a Bevy ReadOnlySystem.
/// trait for executing a system with some Input and Output
pub trait ReadHandler<Input=(), Output=()> {
fn run(&self, world: &BevyEcs) -> Output;
}
/// Wrapper for storing Handler function pointer and arguments
pub struct ReadHandlerWrapper<System, Args>(pub System, pub Arguments);
// implementation using an HRTB to execute the system.
impl<System, Args, Input, Output> ReadHandler<Input, Output> for ReadHandlerWrapper<System, Args>
where
Args: 'static,
Output: 'static,
System: for<'i> ReadOnlySystem<In=InRef<'i, Args>, Out=Output>
// ^^^^^^^ Error occurs here
{
fn run(&self, world: &World) -> Output {
todo!()
}
}
The Error is:
error[E0582]: binding for associated type `In` references lifetime `'i`, which does not appear in the trait input types
--> src/handler/mod.rs:106:31
|
106 | System: for<'i> ReadOnlySystem<In=InRef<'i, Arg>, Out=Output>
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
I don't want to have to clone Args into the system every single time its' ran, because it may be a rather large struct. Any help is greatly appreciated.
The Dark Arts of Advanced and Unsafe Rust Programming