Skip to content

Commit 6e4ca5a

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

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

crates/bevy_ecs/src/system/system_param.rs

+7-11
Original file line numberDiff line numberDiff line change
@@ -218,11 +218,14 @@ 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
222+
/// and world metadata. No data can be written.
223+
/// This should be called before [`SystemParam::get_param`] when running systems
224+
/// to ensure data can be acquired without panic.
222225
///
223226
/// # Safety
224227
///
225-
/// - The passed [`UnsafeWorldCell`] must have read access to any world data
228+
/// - The passed [`UnsafeWorldCell`] must have read-only access to world data
226229
/// registered in [`init_state`](SystemParam::init_state).
227230
/// - `world` must be the same [`World`] that was used to initialize [`state`](SystemParam::init_state).
228231
unsafe fn validate_param(
@@ -2307,16 +2310,9 @@ trait DynParamState: Sync + Send {
23072310
/// Queues any deferred mutations to be applied at the next [`apply_deferred`](crate::prelude::apply_deferred).
23082311
fn queue(&mut self, system_meta: &SystemMeta, world: DeferredWorld);
23092312

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
2313+
/// Refer to [SystemParam::validate_param].
23162314
///
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).
2315+
/// # Safety: Refer to [SystemParam::validate_param].
23202316
unsafe fn validate_param(&self, system_meta: &SystemMeta, world: UnsafeWorldCell) -> bool;
23212317
}
23222318

0 commit comments

Comments
 (0)