pub struct RefCell<T: ?Sized> { /* private fields */ }
Expand description
A clone of the standard library’s RefCell
type.
Implementations§
Source§impl<T> RefCell<T>
impl<T> RefCell<T>
Sourcepub fn into_inner(self) -> T
pub fn into_inner(self) -> T
Consumes the RefCell
, returning the wrapped value.
Source§impl<T: ?Sized> RefCell<T>
impl<T: ?Sized> RefCell<T>
Sourcepub fn borrow<'a>(&'a self) -> Ref<'a, T>
pub fn borrow<'a>(&'a self) -> Ref<'a, 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.
Sourcepub fn borrow_mut<'a>(&'a self) -> RefMut<'a, T>
pub fn borrow_mut<'a>(&'a self) -> RefMut<'a, 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.
Trait Implementations§
impl<T: ?Sized + Eq> Eq for RefCell<T>
impl<T> Send for RefCell<T>
Auto Trait Implementations§
impl<T> !Freeze for RefCell<T>
impl<T> !RefUnwindSafe for RefCell<T>
impl<T> !Sync for RefCell<T>
impl<T> Unpin for RefCell<T>
impl<T> UnwindSafe for RefCell<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