pub struct AtomicRefCell<T: ?Sized> { /* private fields */ }Expand description
A threadsafe analogue to RefCell.
Implementations§
Source§impl<T> AtomicRefCell<T>
impl<T> AtomicRefCell<T>
Sourcepub fn new(value: T) -> AtomicRefCell<T>
pub fn new(value: T) -> AtomicRefCell<T>
Creates a new AtomicRefCell containing value.
Sourcepub fn into_inner(self) -> T
pub fn into_inner(self) -> T
Consumes the AtomicRefCell, returning the wrapped value.
Source§impl<T: ?Sized> AtomicRefCell<T>
impl<T: ?Sized> AtomicRefCell<T>
Sourcepub fn try_borrow(&self) -> Result<AtomicRef<'_, T>, BorrowError>
pub fn try_borrow(&self) -> Result<AtomicRef<'_, T>, BorrowError>
Attempts to immutably borrow the wrapped value, but instead of panicking
on a failed borrow, returns Err.
Sourcepub fn borrow_mut(&self) -> AtomicRefMut<'_, T>
pub fn borrow_mut(&self) -> AtomicRefMut<'_, T>
Mutably borrows the wrapped value.
Sourcepub fn try_borrow_mut(&self) -> Result<AtomicRefMut<'_, T>, BorrowMutError>
pub fn try_borrow_mut(&self) -> Result<AtomicRefMut<'_, T>, BorrowMutError>
Attempts to mutably borrow the wrapped value, but instead of panicking
on a failed borrow, returns Err.
Trait Implementations§
Source§impl<T: Clone> Clone for AtomicRefCell<T>
impl<T: Clone> Clone for AtomicRefCell<T>
Source§fn clone(&self) -> AtomicRefCell<T>
fn clone(&self) -> AtomicRefCell<T>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<T: Default> Default for AtomicRefCell<T>
impl<T: Default> Default for AtomicRefCell<T>
Source§fn default() -> AtomicRefCell<T>
fn default() -> AtomicRefCell<T>
Returns the “default value” for a type. Read more
Source§impl<T> From<T> for AtomicRefCell<T>
impl<T> From<T> for AtomicRefCell<T>
Source§fn from(t: T) -> AtomicRefCell<T>
fn from(t: T) -> AtomicRefCell<T>
Converts to this type from the input type.
Source§impl<T: ?Sized> NonBlockingGuardedBorrow<T> for AtomicRefCell<T>
impl<T: ?Sized> NonBlockingGuardedBorrow<T> for AtomicRefCell<T>
Source§type Guard<'a> = AtomicRef<'a, T>
where
T: 'a
type Guard<'a> = AtomicRef<'a, T> where T: 'a
The guard type (for example,
std::cell::Ref<'a, T>.)Source§type BorrowError<'a> = BorrowError
where
T: 'a
type BorrowError<'a> = BorrowError where T: 'a
The type returned in the case the value cannot be borrowed.
Source§fn try_nonblocking_guarded_borrow(
&self,
) -> Result<Self::Guard<'_>, Self::BorrowError<'_>>
fn try_nonblocking_guarded_borrow( &self, ) -> Result<Self::Guard<'_>, Self::BorrowError<'_>>
Attempt to perform the borrow.
Source§impl<T: ?Sized> NonBlockingGuardedBorrowMut<T> for AtomicRefCell<T>
impl<T: ?Sized> NonBlockingGuardedBorrowMut<T> for AtomicRefCell<T>
Source§type GuardMut<'a> = AtomicRefMut<'a, T>
where
T: 'a
type GuardMut<'a> = AtomicRefMut<'a, T> where T: 'a
The guard type (for example,
std::cell::RefMut<'a, T>.)Source§type BorrowMutError<'a> = BorrowMutError
where
T: 'a
type BorrowMutError<'a> = BorrowMutError where T: 'a
The type returned in the case the value cannot be borrowed.
Source§fn try_nonblocking_guarded_borrow_mut(
&self,
) -> Result<Self::GuardMut<'_>, Self::BorrowMutError<'_>>
fn try_nonblocking_guarded_borrow_mut( &self, ) -> Result<Self::GuardMut<'_>, Self::BorrowMutError<'_>>
Attempt to perform the borrow.
Source§impl<T: ?Sized> NonBlockingGuardedMutBorrowMut<T> for AtomicRefCell<T>
impl<T: ?Sized> NonBlockingGuardedMutBorrowMut<T> for AtomicRefCell<T>
Source§type MutGuardMut<'a> = &'a mut T
where
T: 'a
type MutGuardMut<'a> = &'a mut T where T: 'a
The guard type (for example,
std::sync::RwLockWriteGuard<'a, T>.)Source§type MutBorrowMutError<'a> = Infallible
where
T: 'a
type MutBorrowMutError<'a> = Infallible where T: 'a
The type returned in the case the value cannot be borrowed.
Source§fn try_nonblocking_guarded_mut_borrow_mut(
&mut self,
) -> Result<Self::MutGuardMut<'_>, Self::MutBorrowMutError<'_>>
fn try_nonblocking_guarded_mut_borrow_mut( &mut self, ) -> Result<Self::MutGuardMut<'_>, Self::MutBorrowMutError<'_>>
Attempt to perform the borrow.
Source§impl<T: ?Sized + Ord> Ord for AtomicRefCell<T>
impl<T: ?Sized + Ord> Ord for AtomicRefCell<T>
Source§fn cmp(&self, other: &AtomicRefCell<T>) -> Ordering
fn cmp(&self, other: &AtomicRefCell<T>) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl<T: ?Sized + PartialOrd> PartialOrd for AtomicRefCell<T>
impl<T: ?Sized + PartialOrd> PartialOrd for AtomicRefCell<T>
impl<T: ?Sized + Eq> Eq for AtomicRefCell<T>
impl<T: ?Sized + Send> Send for AtomicRefCell<T>
impl<T: ?Sized + Send + Sync> Sync for AtomicRefCell<T>
Auto Trait Implementations§
impl<T> !Freeze for AtomicRefCell<T>
impl<T> !RefUnwindSafe for AtomicRefCell<T>
impl<T> Unpin for AtomicRefCell<T>
impl<T> UnwindSafe for AtomicRefCell<T>where
T: UnwindSafe + ?Sized,
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