pub struct ResourceSet { /* private fields */ }
Expand description
Store a set of arbitrary types inside AtomicRefCell
s, and then access them for either reading
or writing.
Implementations§
Source§impl ResourceSet
impl ResourceSet
pub fn new() -> Self
pub fn insert<T>(&mut self, r: T) -> Option<T>where
T: Send + 'static,
pub fn remove<T>(&mut self) -> Option<T>where
T: Send + 'static,
pub fn contains<T>(&self) -> boolwhere
T: Send + 'static,
Sourcepub fn borrow<T>(&self) -> AtomicRef<'_, T>
pub fn borrow<T>(&self) -> AtomicRef<'_, T>
Borrow the given resource immutably.
§Panics
Panics if the resource has not been inserted or is already borrowed mutably.
Sourcepub fn borrow_mut<T>(&self) -> AtomicRefMut<'_, T>where
T: Send + 'static,
pub fn borrow_mut<T>(&self) -> AtomicRefMut<'_, T>where
T: Send + 'static,
Borrow the given resource mutably.
§Panics
Panics if the resource has not been inserted or is already borrowed.
Sourcepub fn get_mut<T>(&mut self) -> &mut Twhere
T: Send + 'static,
pub fn get_mut<T>(&mut self) -> &mut Twhere
T: Send + 'static,
§Panics
Panics if the resource has not been inserted.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ResourceSet
impl !RefUnwindSafe for ResourceSet
impl Send for ResourceSet
impl Sync for ResourceSet
impl Unpin for ResourceSet
impl !UnwindSafe for ResourceSet
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more