I am using specs crate to do some work. The feature I am implementing is to statistic time cost by all the systems, so I rewrite the add function like this
pub struct EcsDispatcherBuilder<'a, 'b> {
builder: DispatcherBuilder<'a, 'b>,
profile: bool,
}
impl<'a, 'b> EcsDispatcherBuilder<'a, 'b> {
pub fn add<T>(&mut self, system: T, name: &str, dep: &[&str])
where
T: for<'c> System<'c> + Send + 'a,
for<'c> <T as System<'c>>::SystemData: SystemData<'c>,
{
if self.profile {
self.builder
.add(StatisticSystem(name.into(), system), name, dep);
} else {
self.builder.add(system, name, dep);
}
}
}
And a normal system like this
impl<'a> System<'a> for CloseSystem {
type SystemData = (
Entities<'a>,
WriteStorage<'a, Closing>,
ReadStorage<'a, NetToken>,
Read<'a, LazyUpdate>,
Read<'a, BytesSender>,
);
...
}
I am sure CloseSystem::SystemData implements SystemData, because System::SystemData is bounded to DynamicSystemData, and all DynamicSystemData implements SystemData, CloseSystem compiles ok until I really call an add function like this.
builder.add(CloseSystem, "close", &[]);
error[E0277]: the trait bound `for<'c> <_ as specs::System<'c>>::SystemData: SystemData<'c>` is not satisfied
--> src\lib.rs:235:17
|
235 | builder.add(CloseSystem, "close", &[]);
| ^^^ the trait `for<'c> SystemData<'c>` is not implemented for `<_ as specs::System<'c>>::SystemData`
Can somebody help me out? Thanks.