pub struct RefCell<T>where
T: ?Sized,{ /* private fields */ }
Expand description
A clone of the standard library’s RefCell
type.
Implementations§
§impl<T> RefCell<T>
impl<T> RefCell<T>
pub fn into_inner(self) -> T
pub fn into_inner(self) -> T
Consumes the RefCell
, returning the wrapped value.
§impl<T> RefCell<T>where
T: ?Sized,
impl<T> RefCell<T>where T: ?Sized,
pub fn borrow(&self) -> Ref<'_, T>
pub fn borrow(&self) -> Ref<'_, T>
Immutably borrows the wrapped value.
The borrow lasts until the returned Ref
exits scope. Multiple
immutable borrows can be taken out at the same time.
Panics
Panics if the value is currently mutably borrowed.
pub fn try_borrow(&self) -> Result<Ref<'_, T>, BorrowError>
pub fn try_borrow(&self) -> Result<Ref<'_, T>, BorrowError>
Immutably borrows the wrapped value.
The borrow lasts until the returned Ref
exits scope. Multiple
immutable borrows can be taken out at the same time.
Panics
Panics if the value is currently mutably borrowed.
pub fn borrow_mut(&self) -> RefMut<'_, T>
pub fn borrow_mut(&self) -> RefMut<'_, T>
Mutably borrows the wrapped value.
The borrow lasts until the returned RefMut
exits scope. The value
cannot be borrowed while this borrow is active.
Panics
Panics if the value is currently borrowed.
pub fn try_borrow_mut(&self) -> Result<RefMut<'_, T>, BorrowMutError>
pub fn try_borrow_mut(&self) -> Result<RefMut<'_, T>, BorrowMutError>
Tries borrowing the wrapped value mutably.
The borrow lasts until the returned RefMut
exits scope. The value
cannot be borrowed while this borrow is active.
Trait Implementations§
§impl<T> PartialEq<RefCell<T>> for RefCell<T>where
T: PartialEq<T> + ?Sized,
impl<T> PartialEq<RefCell<T>> for RefCell<T>where T: PartialEq<T> + ?Sized,
impl<T> Eq for RefCell<T>where T: Eq + ?Sized,
impl<T> Send for RefCell<T>where T: Send + ?Sized,
Auto Trait Implementations§
impl<T> !RefUnwindSafe for RefCell<T>
impl<T> !Sync for RefCell<T>
impl<T: ?Sized> Unpin for RefCell<T>where T: Unpin,
impl<T: ?Sized> UnwindSafe for RefCell<T>where T: UnwindSafe,
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
§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.