pub struct Resources { /* private fields */ }Expand description
Type-keyed singleton storage: one value per resource type.
Implementations§
Source§impl Resources
impl Resources
Sourcepub fn insert<T: Any + Send>(&mut self, value: T) -> Option<T>
pub fn insert<T: Any + Send>(&mut self, value: T) -> Option<T>
Insert a resource, returning the previous instance of the same type if one was present. Replaces in place when the type is already present, so a per-frame republish reuses the existing allocation.
Sourcepub fn get_mut<T: Any>(&mut self) -> Option<&mut T>
pub fn get_mut<T: Any>(&mut self) -> Option<&mut T>
Mutably borrow the resource of type T, if one is present.
Sourcepub fn remove<T: Any>(&mut self) -> Option<T>
pub fn remove<T: Any>(&mut self) -> Option<T>
Remove and return the resource of type T, if one is present.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Resources
impl !Sync for Resources
impl !UnwindSafe for Resources
impl Freeze for Resources
impl Send for Resources
impl Unpin for Resources
impl UnsafeUnpin for Resources
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more