-
So this might be a duplicate of #11203 and/or #11826, however I either didn't understand what the accepted answer suggests, or it doesn't apply to my specific case. Basically, I'm trying to add a generic system to my app, however I get a compiler error:
What sets my case apart from that of #11203 is the convoluted way in which the (non-)system is generic. As for #11826, I feel like I have the exact same scenario, except I did apply @hymm's suggestion to wrap the parameter in Here's a minimal example that triggers the error: use bevy::ecs::system::{SystemParam, SystemParamItem};
use bevy::prelude::*;
use std::marker::PhantomData;
pub trait HasParam: 'static + Send + Sync {
type Param: SystemParam;
}
pub struct GenericPlugin<T> {
generic_type: PhantomData<T>,
}
impl<T> Default for GenericPlugin<T> {
fn default() -> Self {
GenericPlugin {
generic_type: PhantomData::default(),
}
}
}
fn generic_system<T: HasParam>(_pg_param: SystemParamItem<T::Param>) {}
impl<T> Plugin for GenericPlugin<T>
where
T: HasParam,
{
fn build(&self, app: &mut App) {
app.add_systems(Update, generic_system::<T>); // compiler error!
}
} |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Looking again at the example posted here, wrapping the parameter in |
Beta Was this translation helpful? Give feedback.
Looking again at the example posted here, wrapping the parameter in
StaticSystemParam
does the trick.