diff --git a/crates/bevy_ecs/src/schedule/condition.rs b/crates/bevy_ecs/src/schedule/condition.rs index 957eb806d150c..66b3f51644ea2 100644 --- a/crates/bevy_ecs/src/schedule/condition.rs +++ b/crates/bevy_ecs/src/schedule/condition.rs @@ -13,13 +13,20 @@ impl Condition for F where F: sealed::Condition {} mod sealed { use crate::system::{IntoSystem, ReadOnlySystem}; - pub trait Condition: IntoSystem<(), bool, Params> {} + pub trait Condition: + IntoSystem<(), bool, Params, System = Self::ReadOnlySystem> + { + // This associated type is necessary to let the compiler + // know that `Self::System` is `ReadOnlySystem`. + type ReadOnlySystem: ReadOnlySystem; + } impl Condition for F where F: IntoSystem<(), bool, Params>, F::System: ReadOnlySystem, { + type ReadOnlySystem = F::System; } } @@ -133,12 +140,9 @@ pub mod common_conditions { /// # /// # fn my_system() { unreachable!() } /// ``` - pub fn not>( - condition: C, - ) -> impl ReadOnlySystem - where - C::System: ReadOnlySystem, - { + pub fn not( + condition: impl Condition, + ) -> impl ReadOnlySystem { condition.pipe(|In(val): In| !val) } }