pub struct BetterRefCell<T: ?Sized> { /* private fields */ }Implementations§
Source§impl<T> BetterRefCell<T>
impl<T> BetterRefCell<T>
Source§impl<T: ?Sized> BetterRefCell<T>
impl<T: ?Sized> BetterRefCell<T>
pub fn borrow(&self) -> Ref<'_, T>
pub fn try_borrow(&self) -> Result<Ref<'_, T>, BorrowError>
pub fn borrow_mut(&self) -> RefMut<'_, T>
pub fn try_borrow_mut(&self) -> Result<RefMut<'_, T>, BorrowMutError>
pub fn as_ptr(&self) -> *mut T
pub fn get_mut(&mut self) -> &mut T
pub unsafe fn try_borrow_unguarded(&self) -> Result<&T, BorrowError>
Source§impl<T: ?Sized> BetterRefCell<T>
impl<T: ?Sized> BetterRefCell<T>
Sourcepub fn unborrow<R>(&self, borrowed: &mut T, f: impl FnOnce() -> R) -> R
pub fn unborrow<R>(&self, borrowed: &mut T, f: impl FnOnce() -> R) -> R
§Panics
This function panics if any of the following conditions are met:
- The
borrowedreference does not point to the internal value stored in thisBetterRefCell. - Any borrow guards obtained from this
BetterRefCellwithinfare still active afterfcompletes.
Sourcepub unsafe fn unborrow_unchecked<R>(
&self,
borrowed: &mut T,
f: impl FnOnce() -> R,
) -> R
pub unsafe fn unborrow_unchecked<R>( &self, borrowed: &mut T, f: impl FnOnce() -> R, ) -> R
§Safety
This function is safe to call if all of these conditions are met:
- The
borrowedreference must point to the internal value stored in thisBetterRefCell. - Any borrow guards obtained from this
BetterRefCelloutside offmust not be used withinf. - All borrow guards obtained from this
BetterRefCellwithinfmust be dropped beforefreturns.
Sourcepub fn unborrow_ref<R>(&self, borrowed: &T, f: impl FnOnce() -> R) -> R
pub fn unborrow_ref<R>(&self, borrowed: &T, f: impl FnOnce() -> R) -> R
§Panics
This function panics if any of the following conditions are met:
- The
borrowedreference does not point to the internal value stored in thisBetterRefCell. - Any
Refs obtained from thisBetterRefCellwithinfare still active afterfcompletes, while at least oneRefMutfor thisBetterRefCellexists outside the scope off.
Sourcepub unsafe fn unborrow_ref_unchecked<R>(
&self,
borrowed: &T,
f: impl FnOnce() -> R,
) -> R
pub unsafe fn unborrow_ref_unchecked<R>( &self, borrowed: &T, f: impl FnOnce() -> R, ) -> R
§Safety
This function is safe to call if all of these conditions are met:
- The
borrowedreference must point to the internal value stored in thisBetterRefCell. - Any borrow guards obtained from this
BetterRefCelloutside offmust not be used withinf. - All borrow guards obtained from this
BetterRefCellwithinfmust be dropped beforefreturns.
Trait Implementations§
Source§impl<T: Clone> Clone for BetterRefCell<T>
impl<T: Clone> Clone for BetterRefCell<T>
Source§impl<T: Default> Default for BetterRefCell<T>
impl<T: Default> Default for BetterRefCell<T>
Source§impl<T> From<T> for BetterRefCell<T>
impl<T> From<T> for BetterRefCell<T>
Source§impl<T: ?Sized + Ord> Ord for BetterRefCell<T>
impl<T: ?Sized + Ord> Ord for BetterRefCell<T>
Source§impl<T: ?Sized + PartialOrd> PartialOrd for BetterRefCell<T>
impl<T: ?Sized + PartialOrd> PartialOrd for BetterRefCell<T>
impl<T: ?Sized + Eq> Eq for BetterRefCell<T>
Auto Trait Implementations§
impl<T> !Freeze for BetterRefCell<T>
impl<T> !RefUnwindSafe for BetterRefCell<T>
impl<T> !Send for BetterRefCell<T>
impl<T> !Sync for BetterRefCell<T>
impl<T> Unpin for BetterRefCell<T>
impl<T> UnwindSafe for BetterRefCell<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
Mutably borrows from an owned value. Read more