Skip to content

Commit 42f6e7e

Browse files
Polish comments for the example
1 parent 27ed3f9 commit 42f6e7e

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

examples/ecs/fallible_params.rs

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,25 @@
11
//! This example demonstrates how fallible parameters can prevent their systems
22
//! from running if their acquiry conditions aren't met.
33
//!
4-
//! Fallible parameters include:
5-
//! - [`Res<R>`], [`ResMut<R>`] - Resource has to exist.
6-
//! - [`Single<D, F>`] - There must be exactly one matching entity.
7-
//! - [`Option<Single<D, F>>`] - There must be zero or one matching entity.
8-
//! - [`Populated<D, F>`] - There must be at least one matching entity.
4+
//! Fallible system parameters include:
5+
//! - [`Res<R>`], [`ResMut<R>`] - Resource has to exist, and the [`GLOBAL_ERROR_HANDLER`] will be called if it doesn't.
6+
//! - [`Single<D, F>`] - There must be exactly one matching entity, but the system will be silently skipped otherwise.
7+
//! - [`Option<Single<D, F>>`] - There must be zero or one matching entity. The system will be silently skipped if there are more.
8+
//! - [`Populated<D, F>`] - There must be at least one matching entity, but the system will be silently skipped otherwise.
99
//!
10-
//! To learn more about setting the fallback behavior for when a parameter fails to be fetched,
10+
//! Other system parameters, such as [`Query`], will never fail validation: returning a query with no matching entities is valid.
11+
//!
12+
//! The result of failed system parameter validation is determined by the [`ValidationOutcome`] returned
13+
//! by [`SystemParam::validate_param`] for each system parameter.
14+
//! Each system will pass, fail, or skip based on the joint outcome of all its parameters,
15+
//! according to the rules defined in [`ValidationOutcome::combine`].
16+
//!
17+
//! To learn more about setting the fallback behavior for [`ValidationOutcome`] failures,
1118
//! please see the `error_handling.rs` example.
19+
//!
20+
//! [`ValidationOutcome`]: bevy::ecs::system::ValidationOutcome
21+
//! [`ValidationOutcome::combine`]: bevy::ecs::system::ValidationOutcome::combine
22+
//! [`SystemParam::validate_param`]: bevy::ecs::system::SystemParam::validate_param
1223
1324
use bevy::ecs::error::{warn, GLOBAL_ERROR_HANDLER};
1425
use bevy::prelude::*;
@@ -111,7 +122,7 @@ fn user_input(
111122
}
112123

113124
// System that moves the enemies in a circle.
114-
// Only runs if there are enemies.
125+
// Only runs if there are enemies, due to the `Populated` parameter.
115126
fn move_targets(mut enemies: Populated<(&mut Transform, &mut Enemy)>, time: Res<Time>) {
116127
for (mut transform, mut target) in &mut *enemies {
117128
target.rotation += target.rotation_speed * time.delta_secs();

0 commit comments

Comments
 (0)