pub struct CheckedRcRefCell<T: ?Sized>(pub Rc<RefCell<T>>);alloc only.Expand description
A thin wrapper around Rc<RefCell<T>> which implements the container traits differently:
CheckedRcRefCell<T> is fallible, but not fragile.
Note that Rc<RefCell<T>> is an infallible but fragile container, essentially interpreting
any circumstance which would return an error in CheckedRcRefCell<T> as instead being a bug
and panicking. The user of a fragile container must uphold greater restrictions, in exchange for
infallibility. Those restrictions still effectively apply here, but violating them results in
errors being returned instead of being fatal.
Tuple Fields§
§0: Rc<RefCell<T>>Trait Implementations§
Source§impl<T: ?Sized> Clone for CheckedRcRefCell<T>
impl<T: ?Sized> Clone for CheckedRcRefCell<T>
Source§impl<T: Default + ?Sized> Default for CheckedRcRefCell<T>
impl<T: Default + ?Sized> Default for CheckedRcRefCell<T>
Source§fn default() -> CheckedRcRefCell<T>
fn default() -> CheckedRcRefCell<T>
Source§impl<T: ?Sized> FragileTryContainer<T> for CheckedRcRefCell<T>
impl<T: ?Sized> FragileTryContainer<T> for CheckedRcRefCell<T>
Source§fn into_inner(self) -> Option<T>where
T: Sized,
fn into_inner(self) -> Option<T>where
T: Sized,
Attempt to retrieve the inner T from the container.
Behaves identically to Rc::into_inner.
Source§fn try_get_ref(&self) -> Result<Self::Ref<'_>, Self::RefError>
fn try_get_ref(&self) -> Result<Self::Ref<'_>, Self::RefError>
Immutably borrows the inner T, returning an error if the value is currently mutably
borrowed.
Behaves identically to RefCell::try_borrow.
Source§type Ref<'a> = Ref<'a, T>
where
T: 'a
type Ref<'a> = Ref<'a, T> where T: 'a
Source§type RefError = BorrowError
type RefError = BorrowError
try_get_ref. This type should implement
std::error::Error. Read moreSource§fn new_container(t: T) -> Selfwhere
T: Sized,
fn new_container(t: T) -> Selfwhere
T: Sized,
T.Source§impl<T: ?Sized> FragileTryMutContainer<T> for CheckedRcRefCell<T>
impl<T: ?Sized> FragileTryMutContainer<T> for CheckedRcRefCell<T>
Source§fn try_get_mut(&mut self) -> Result<Self::RefMut<'_>, Self::RefMutError>
fn try_get_mut(&mut self) -> Result<Self::RefMut<'_>, Self::RefMutError>
Mutably borrows the inner T, returning an error if the value is currently borrowed.
Behaves identically to RefCell::try_borrow_mut.
Source§type RefMut<'a> = RefMut<'a, T>
where
T: 'a
type RefMut<'a> = RefMut<'a, T> where T: 'a
Source§type RefMutError = BorrowMutError
type RefMutError = BorrowMutError
try_get_mut. This type should implement
std::error::Error. Read moreSource§impl<T: Ord + ?Sized> Ord for CheckedRcRefCell<T>
impl<T: Ord + ?Sized> Ord for CheckedRcRefCell<T>
Source§fn cmp(&self, other: &CheckedRcRefCell<T>) -> Ordering
fn cmp(&self, other: &CheckedRcRefCell<T>) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl<T: PartialOrd + ?Sized> PartialOrd for CheckedRcRefCell<T>
impl<T: PartialOrd + ?Sized> PartialOrd for CheckedRcRefCell<T>
impl<T: Eq + ?Sized> Eq for CheckedRcRefCell<T>
impl<T: ?Sized> StructuralPartialEq for CheckedRcRefCell<T>
impl<T: ?Sized> TryContainer<T> for CheckedRcRefCell<T>
impl<T: ?Sized> TryMutContainer<T> for CheckedRcRefCell<T>
Auto Trait Implementations§
impl<T> Freeze for CheckedRcRefCell<T>where
T: ?Sized,
impl<T> !RefUnwindSafe for CheckedRcRefCell<T>
impl<T> !Send for CheckedRcRefCell<T>
impl<T> !Sync for CheckedRcRefCell<T>
impl<T> Unpin for CheckedRcRefCell<T>where
T: ?Sized,
impl<T> !UnwindSafe for CheckedRcRefCell<T>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FragileContainer<T> for Twhere
T: ?Sized,
impl<T> FragileContainer<T> for Twhere
T: ?Sized,
Source§fn get_ref(&self) -> <T as FragileTryContainer<T>>::Ref<'_>
fn get_ref(&self) -> <T as FragileTryContainer<T>>::Ref<'_>
Infallibly get immutable access to the T.
Source§impl<T> FragileMutContainer<T> for Twhere
T: ?Sized,
impl<T> FragileMutContainer<T> for Twhere
T: ?Sized,
Source§fn get_mut(&mut self) -> <T as FragileTryMutContainer<T>>::RefMut<'_>
fn get_mut(&mut self) -> <T as FragileTryMutContainer<T>>::RefMut<'_>
Infallibly get mutable access to the T.
Source§impl<T> FragileTryContainer<T> for Twhere
T: ?Sized,
impl<T> FragileTryContainer<T> for Twhere
T: ?Sized,
Source§fn into_inner(self) -> Option<T>
fn into_inner(self) -> Option<T>
Infallibly get the T.
Source§fn try_get_ref(
&self,
) -> Result<<T as FragileTryContainer<T>>::Ref<'_>, <T as FragileTryContainer<T>>::RefError>
fn try_get_ref( &self, ) -> Result<<T as FragileTryContainer<T>>::Ref<'_>, <T as FragileTryContainer<T>>::RefError>
Infallibly get immutable access to the T.
Source§type RefError = Infallible
type RefError = Infallible
try_get_ref. This type should implement
std::error::Error. Read moreSource§fn new_container(t: T) -> T
fn new_container(t: T) -> T
T.Source§impl<T> FragileTryMutContainer<T> for Twhere
T: ?Sized,
impl<T> FragileTryMutContainer<T> for Twhere
T: ?Sized,
Source§fn try_get_mut(
&mut self,
) -> Result<<T as FragileTryMutContainer<T>>::RefMut<'_>, <T as FragileTryMutContainer<T>>::RefMutError>
fn try_get_mut( &mut self, ) -> Result<<T as FragileTryMutContainer<T>>::RefMut<'_>, <T as FragileTryMutContainer<T>>::RefMutError>
Infallibly get mutable access to the T.
Source§type RefMut<'a> = &'a mut T
where
T: 'a
type RefMut<'a> = &'a mut T where T: 'a
Source§type RefMutError = Infallible
type RefMutError = Infallible
try_get_mut. This type should implement
std::error::Error. Read more