Skip to content

Commit 7896012

Browse files
committed
refine docs
1 parent 8d0af32 commit 7896012

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

crates/bevy_ecs/src/change_detection.rs

+8-10
Original file line numberDiff line numberDiff line change
@@ -542,12 +542,11 @@ impl<'w> From<TicksMut<'w>> for Ticks<'w> {
542542
/// See the [`Resource`] documentation for usage.
543543
///
544544
/// If you need a unique mutable borrow, use [`ResMut`] instead.
545+
///
546+
/// This [`SystemParam`](crate::system::SystemParam) fails validation if resource doesn't exist.
547+
/// This will cause systems that use it to be skipped.
545548
///
546-
/// # Panics
547-
///
548-
/// Panics when used as a [`SystemParameter`](crate::system::SystemParam) if the resource does not exist.
549-
///
550-
/// Use `Option<Res<T>>` instead if the resource might not always exist.
549+
/// Use [`Option<Res<T>>`] instead if the resource might not always exist.
551550
pub struct Res<'w, T: ?Sized + Resource> {
552551
pub(crate) value: &'w T,
553552
pub(crate) ticks: Ticks<'w>,
@@ -621,12 +620,11 @@ impl_debug!(Res<'w, T>, Resource);
621620
/// See the [`Resource`] documentation for usage.
622621
///
623622
/// If you need a shared borrow, use [`Res`] instead.
623+
///
624+
/// This [`SystemParam`](crate::system::SystemParam) fails validation if resource doesn't exist.
625+
/// This will cause systems that use it to be skipped.
624626
///
625-
/// # Panics
626-
///
627-
/// Panics when used as a [`SystemParam`](crate::system::SystemParam) if the resource does not exist.
628-
///
629-
/// Use `Option<ResMut<T>>` instead if the resource might not always exist.
627+
/// Use [`Option<ResMut<T>>`] instead if the resource might not always exist.
630628
pub struct ResMut<'w, T: ?Sized + Resource> {
631629
pub(crate) value: &'w mut T,
632630
pub(crate) ticks: TicksMut<'w>,

crates/bevy_ecs/src/system/query.rs

+10-8
Original file line numberDiff line numberDiff line change
@@ -1636,11 +1636,12 @@ impl<'w, 'q, Q: QueryData, F: QueryFilter> From<&'q mut Query<'w, '_, Q, F>>
16361636

16371637
/// [System parameter] that provides readonly access to single entity's components, much like [`Query::single`].
16381638
///
1639-
/// For meaning behind the generic arguments refer to [`Query`].
1639+
/// This [`SystemParam`](crate::system::SystemParam) fails validation if zero or more than one matching entity exists.
1640+
/// This will cause systems that use it to be skipped.
16401641
///
1641-
/// When used as a parameter in a system, multiple matching will prevent the system from running.
1642-
/// System skipping will also happen when no matching entity exists, but the behavior can be
1643-
/// handled by using [`Option<QuerySingle>`] instead, which allows zero or one matching entity.
1642+
/// Use [`Option<QuerySingle<D, F>>`] instead if no matching entities can exist.
1643+
///
1644+
/// See [`Query`] for meaning behind the generic arguments.
16441645
pub struct QuerySingle<'w, D: ReadOnlyQueryData, F: QueryFilter = ()> {
16451646
pub(crate) single: <D::ReadOnly as WorldQuery>::Item<'w>,
16461647
pub(crate) _filter: PhantomData<F>,
@@ -1656,11 +1657,12 @@ impl<'w, D: ReadOnlyQueryData, F: QueryFilter> Deref for QuerySingle<'w, D, F> {
16561657

16571658
/// [System parameter] that provides mutable access to single entity's components, much like [`Query::single_mut`].
16581659
///
1659-
/// For meaning behind the generic arguments refer to [`Query`].
1660+
/// This [`SystemParam`](crate::system::SystemParam) fails validation if zero or more than one matching entity exists.
1661+
/// This will cause systems that use it to be skipped.
1662+
///
1663+
/// Use [`Option<QuerySingleMut<D, F>>`] instead if no matching entities can exist.
16601664
///
1661-
/// When used as a parameter in a system, multiple matching will prevent the system from running.
1662-
/// System skipping will also happen when no matching entity exists, but the behavior can be
1663-
/// handled by using [`Option<QuerySingleMut>`] instead, which allows zero or one matching entity.
1665+
/// See [`Query`] for meaning behind the generic arguments.
16641666
pub struct QuerySingleMut<'w, D: QueryData, F: QueryFilter = ()> {
16651667
pub(crate) single: D::Item<'w>,
16661668
pub(crate) _filter: PhantomData<F>,

0 commit comments

Comments
 (0)