Combining plugins with chain (pipe) systems is very complex #6441
Answered
by
mockersf
alice-i-cecile
asked this question in
Q&A
-
Bevy version0.8 What you didI wanted to make a plugin that abstracts over different ways to handle errors from a shared system (for building a wheel menu widget). We can get a skeleton of the plugin using the following definition. enum MyError {
Rainy,
Sunny,
}
fn error_producing_system() -> Result<(), MyErr> {
Ok(())
}
pub struct MyPlugin<H, Out, Params>
where
H: IntoSystem<Result<(), MyError>, Out, Params> + Send + Sync + 'static,
Out: Send + Sync + 'static,
Params: Send + Sync + 'static,
{
handler: H,
_phantom: PhantomData<(Out, Params)>,
}
impl<
H: IntoSystem<Result<C, NoWheelSelection>, Out, Params> + Send + Sync + 'static,
Out: Send + Sync + 'static,
Params: Send + Sync + 'static,
> Plugin for WheelMenuPlugin<C, H, Out, Params>
{
fn build(&self, app: &mut bevy::prelude::App) {
app.add_system(error_producing_system::<C>.chain(self.handler))
}
} What went wrongThe code above satisfies almost all of the trait bounds, but the The error message received is incredibly noisy, and it's unclear what trait bounds to add to fix this problem. Full error message
|
Beta Was this translation helpful? Give feedback.
Answered by
mockersf
Nov 1, 2022
Replies: 2 comments 3 replies
-
you have two issues:
making |
Beta Was this translation helpful? Give feedback.
3 replies
Answer selected by
alice-i-cecile
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
you have two issues:
Out
type parameter, it should be()
to be able to finish a chainmaking
H
Clone
and removingOut
works for me 👍