Skip to content

Commit 1e21326

Browse files
authored
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.
1 parent 53919c3 commit 1e21326

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

crates/bevy_ecs/src/schedule/condition.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,22 @@ pub type BoxedCondition<In = ()> = Box<dyn ReadOnlySystem<In = In, Out = bool>>;
1313
/// Implemented for functions and closures that convert into [`System<Out=bool>`](crate::system::System)
1414
/// with [read-only](crate::system::ReadOnlySystemParam) parameters.
1515
///
16+
/// # Marker type parameter
17+
///
18+
/// `Condition` trait has `Marker` type parameter, which has no special meaning,
19+
/// but exists to work around the limitation of Rust's trait system.
20+
///
21+
/// Type parameter in return type can be set to `<()>` by calling [`IntoSystem::into_system`],
22+
/// but usually have to be specified when passing a condition to a function.
23+
///
24+
/// ```
25+
/// # use bevy_ecs::schedule::Condition;
26+
/// # use bevy_ecs::system::IntoSystem;
27+
/// fn not_condition<Marker>(a: impl Condition<Marker>) -> impl Condition<()> {
28+
/// IntoSystem::into_system(a.map(|x| !x))
29+
/// }
30+
/// ```
31+
///
1632
/// # Examples
1733
/// A condition that returns true every other time it's called.
1834
/// ```

0 commit comments

Comments
 (0)