diff --git a/crates/bevy_ecs/src/world/entity_ref.rs b/crates/bevy_ecs/src/world/entity_ref.rs index eabe8cd3f1..1f0cf94cf0 100644 --- a/crates/bevy_ecs/src/world/entity_ref.rs +++ b/crates/bevy_ecs/src/world/entity_ref.rs @@ -1550,6 +1550,11 @@ impl<'w> EntityWorldMut<'w> { /// Temporarily removes the requested resource from the [`World`], runs custom user code, /// then re-adds the resource before returning. /// + /// # Panics + /// + /// Panics if the resource does not exist. + /// Use [`try_resource_scope`](Self::try_resource_scope) instead if you want to handle this case. + /// /// See [`World::resource_scope`] for further details. #[track_caller] pub fn resource_scope( diff --git a/crates/bevy_ecs/src/world/mod.rs b/crates/bevy_ecs/src/world/mod.rs index 57380b489b..f6e3a197ef 100644 --- a/crates/bevy_ecs/src/world/mod.rs +++ b/crates/bevy_ecs/src/world/mod.rs @@ -2551,6 +2551,11 @@ impl World { /// This enables safe simultaneous mutable access to both a resource and the rest of the [`World`]. /// For more complex access patterns, consider using [`SystemState`](crate::system::SystemState). /// + /// # Panics + /// + /// Panics if the resource does not exist. + /// Use [`try_resource_scope`](Self::try_resource_scope) instead if you want to handle this case. + /// /// # Example /// ``` /// use bevy_ecs::prelude::*; @@ -2568,8 +2573,6 @@ impl World { /// }); /// assert_eq!(world.get_resource::().unwrap().0, 2); /// ``` - /// - /// See also [`try_resource_scope`](Self::try_resource_scope). #[track_caller] pub fn resource_scope(&mut self, f: impl FnOnce(&mut World, Mut) -> U) -> U { self.try_resource_scope(f)