From 2cdfb5e583e413d5091fbad1764f259b937dd0be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lena=20Miliz=C3=A9?= Date: Fri, 21 Oct 2022 16:56:08 +0000 Subject: [PATCH] document insert_non_send_resource panics (#6328) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Lena Milizé # Objective Fixes #6277. ## Solution Adds `# Panics` section to [`fn insert_non_send_resource`](http://dev-docs.bevyengine.org/bevy/ecs/world/struct.World.html#method.insert_non_send_resource) documentation, which explains that it panics when called from thread other than main thread. --- crates/bevy_ecs/src/world/mod.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/crates/bevy_ecs/src/world/mod.rs b/crates/bevy_ecs/src/world/mod.rs index 3e45e8c100fea8..a500e2847cbf49 100644 --- a/crates/bevy_ecs/src/world/mod.rs +++ b/crates/bevy_ecs/src/world/mod.rs @@ -763,6 +763,9 @@ impl World { /// `NonSend` resources cannot be sent across threads, /// and do not need the `Send + Sync` bounds. /// Systems with `NonSend` resources are always scheduled on the main thread. + /// + /// # Panics + /// Panics if called from a thread other than the main thread. #[inline] pub fn insert_non_send_resource(&mut self, value: R) { self.validate_non_send_access::();