Skip to content

Commit a9147e6

Browse files
committed
better docs for validate
1 parent 376f55c commit a9147e6

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

crates/bevy_ecs/src/system/system_param.rs

+6-11
Original file line numberDiff line numberDiff line change
@@ -218,11 +218,13 @@ pub unsafe trait SystemParam: Sized {
218218
fn queue(state: &mut Self::State, system_meta: &SystemMeta, world: DeferredWorld) {}
219219

220220
/// Validates that the data can be acquired by [`get_param`](SystemParam::get_param).
221-
/// For systems this means they won't be executed.
221+
/// The [`world`](UnsafeWorldCell) can only be used to read param's data and world metadata.
222+
/// This should be called before [`SystemParam::get_param`] when running systems
223+
/// to ensure data can be acquired without panic.
222224
///
223225
/// # Safety
224226
///
225-
/// - The passed [`UnsafeWorldCell`] must have read access to any world data
227+
/// - The passed [`UnsafeWorldCell`] must have read-only access to world data
226228
/// registered in [`init_state`](SystemParam::init_state).
227229
/// - `world` must be the same [`World`] that was used to initialize [`state`](SystemParam::init_state).
228230
unsafe fn validate_param(
@@ -2307,16 +2309,9 @@ trait DynParamState: Sync + Send {
23072309
/// Queues any deferred mutations to be applied at the next [`apply_deferred`](crate::prelude::apply_deferred).
23082310
fn queue(&mut self, system_meta: &SystemMeta, world: DeferredWorld);
23092311

2310-
/// Validates that the data can be acquired by [`get_param`](SystemParam::get_param).
2311-
/// If validation fails, resource acquisition will fail
2312-
/// and [`SystemParam::get_param`] won't be called.
2313-
/// For systems this means they won't be executed.
2314-
///
2315-
/// # Safety
2312+
/// Refer to [SystemParam::validate_param].
23162313
///
2317-
/// - The passed [`World`] must have access to any world data
2318-
/// registered in [`init_state`](SystemParam::init_state).
2319-
/// - `world` must be the same [`World`] that was used to initialize [`state`](SystemParam::init_state).
2314+
/// # Safety: Refer to [SystemParam::validate_param].
23202315
unsafe fn validate_param(&self, system_meta: &SystemMeta, world: UnsafeWorldCell) -> bool;
23212316
}
23222317

0 commit comments

Comments
 (0)