document insert_non_send_resource panics (#6328)
Signed-off-by: Lena Milizé <me@lvmn.org> # 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.
This commit is contained in:
parent
e8368a0761
commit
b2f223b98f
@ -750,6 +750,10 @@ impl World {
|
|||||||
/// The value given by the [`FromWorld::from_world`] method will be used.
|
/// The value given by the [`FromWorld::from_world`] method will be used.
|
||||||
/// Note that any resource with the `Default` trait automatically implements `FromWorld`,
|
/// Note that any resource with the `Default` trait automatically implements `FromWorld`,
|
||||||
/// and those default values will be here instead.
|
/// and those default values will be here instead.
|
||||||
|
///
|
||||||
|
/// # Panics
|
||||||
|
///
|
||||||
|
/// Panics if called from a thread other than the main thread.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn init_non_send_resource<R: 'static + FromWorld>(&mut self) {
|
pub fn init_non_send_resource<R: 'static + FromWorld>(&mut self) {
|
||||||
if !self.contains_resource::<R>() {
|
if !self.contains_resource::<R>() {
|
||||||
@ -763,6 +767,10 @@ impl World {
|
|||||||
/// `NonSend` resources cannot be sent across threads,
|
/// `NonSend` resources cannot be sent across threads,
|
||||||
/// and do not need the `Send + Sync` bounds.
|
/// and do not need the `Send + Sync` bounds.
|
||||||
/// Systems with `NonSend` resources are always scheduled on the main thread.
|
/// Systems with `NonSend` resources are always scheduled on the main thread.
|
||||||
|
///
|
||||||
|
/// # Panics
|
||||||
|
///
|
||||||
|
/// Panics if called from a thread other than the main thread.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn insert_non_send_resource<R: 'static>(&mut self, value: R) {
|
pub fn insert_non_send_resource<R: 'static>(&mut self, value: R) {
|
||||||
self.validate_non_send_access::<R>();
|
self.validate_non_send_access::<R>();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user