From 1e2132672e01c6ffcb344ec256ee5fd4c9a7f8b5 Mon Sep 17 00:00:00 2001 From: Aldrich Suratos Date: Tue, 28 Nov 2023 01:33:22 +0900 Subject: [PATCH] Copy over docs for `Condition` trait from PR #10718 (#10748) # Objective Resolves #10743. ## Solution Copied over the documentation written by @stepancheng from PR #10718. I left out the lines from the doctest where `<()>` is removed, as that seemed to be the part people couldn't decide on whether to keep or not. --- crates/bevy_ecs/src/schedule/condition.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/crates/bevy_ecs/src/schedule/condition.rs b/crates/bevy_ecs/src/schedule/condition.rs index 92bd416300..4212e1be17 100644 --- a/crates/bevy_ecs/src/schedule/condition.rs +++ b/crates/bevy_ecs/src/schedule/condition.rs @@ -13,6 +13,22 @@ pub type BoxedCondition = Box>; /// Implemented for functions and closures that convert into [`System`](crate::system::System) /// with [read-only](crate::system::ReadOnlySystemParam) parameters. /// +/// # Marker type parameter +/// +/// `Condition` trait has `Marker` type parameter, which has no special meaning, +/// but exists to work around the limitation of Rust's trait system. +/// +/// Type parameter in return type can be set to `<()>` by calling [`IntoSystem::into_system`], +/// but usually have to be specified when passing a condition to a function. +/// +/// ``` +/// # use bevy_ecs::schedule::Condition; +/// # use bevy_ecs::system::IntoSystem; +/// fn not_condition(a: impl Condition) -> impl Condition<()> { +/// IntoSystem::into_system(a.map(|x| !x)) +/// } +/// ``` +/// /// # Examples /// A condition that returns true every other time it's called. /// ```