mirror of
https://github.com/bevyengine/bevy
synced 2024-11-10 07:04:33 +00:00
Added remove_non_send to World (#1716)
Co-authored-by: Carter Anderson <mcanders1@gmail.com>
This commit is contained in:
parent
81b53d15d4
commit
47004dfcb4
1 changed files with 16 additions and 0 deletions
|
@ -520,6 +520,22 @@ impl World {
|
|||
/// Resources are "unique" data of a given type.
|
||||
#[inline]
|
||||
pub fn remove_resource<T: Component>(&mut self) -> Option<T> {
|
||||
// SAFE: T is Send + Sync
|
||||
unsafe { self.remove_resource_unchecked() }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn remove_non_send<T: 'static>(&mut self) -> Option<T> {
|
||||
self.validate_non_send_access::<T>();
|
||||
// SAFE: we are on main thread
|
||||
unsafe { self.remove_resource_unchecked() }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
/// # Safety
|
||||
/// make sure you're on main thread if T isn't Send + Sync
|
||||
#[allow(unused_unsafe)]
|
||||
pub unsafe fn remove_resource_unchecked<T: 'static>(&mut self) -> Option<T> {
|
||||
let component_id = self.components.get_resource_id(TypeId::of::<T>())?;
|
||||
let resource_archetype = self.archetypes.resource_mut();
|
||||
let unique_components = resource_archetype.unique_components_mut();
|
||||
|
|
Loading…
Reference in a new issue