pub struct Ref<'b, T: ?Sized, Tk: Token + ?Sized = BoxToken> { /* private fields */ }Expand description
A wrapper type for an immutably borrowed value from a TokenRefCell.
The token used for borrowing synchronization is also borrowed. Dedicated methods allows reusing the token for further borrowing.
Implementations§
Source§impl<'b, T: ?Sized, Tk: Token + ?Sized> Ref<'b, T, Tk>
impl<'b, T: ?Sized, Tk: Token + ?Sized> Ref<'b, T, Tk>
Sourcepub fn clone(this: &Self) -> Self
pub fn clone(this: &Self) -> Self
Copies a Ref.
This is an associated function that needs to be used as
Ref::clone(...). A Clone implementation or a method would interfere
with the widespread use of cell.borrow(&token).clone() to clone the contents of
a TokenRefCell.
Sourcepub fn reborrow<U: ?Sized>(
&self,
cell: impl FnOnce(&T) -> &TokenRefCell<U, Tk>,
) -> Ref<'_, U, Tk>
pub fn reborrow<U: ?Sized>( &self, cell: impl FnOnce(&T) -> &TokenRefCell<U, Tk>, ) -> Ref<'_, U, Tk>
Sourcepub fn try_reborrow<U: ?Sized>(
&self,
cell: impl FnOnce(&T) -> &TokenRefCell<U, Tk>,
) -> Result<Ref<'_, U, Tk>, BorrowError>
pub fn try_reborrow<U: ?Sized>( &self, cell: impl FnOnce(&T) -> &TokenRefCell<U, Tk>, ) -> Result<Ref<'_, U, Tk>, BorrowError>
Uses borrowed token shared reference to reborrow a TokenRefCell.
Sourcepub fn reborrow_opt<U: ?Sized>(
&self,
cell: impl FnOnce(&T) -> Option<&TokenRefCell<U, Tk>>,
) -> Option<Ref<'_, U, Tk>>
pub fn reborrow_opt<U: ?Sized>( &self, cell: impl FnOnce(&T) -> Option<&TokenRefCell<U, Tk>>, ) -> Option<Ref<'_, U, Tk>>
Uses borrowed token shared reference to optionally reborrow a TokenRefCell.
§Panics
See TokenRefCell::borrow.
Sourcepub fn try_reborrow_opt<U: ?Sized>(
&self,
cell: impl FnOnce(&T) -> Option<&TokenRefCell<U, Tk>>,
) -> Option<Result<Ref<'_, U, Tk>, BorrowError>>
pub fn try_reborrow_opt<U: ?Sized>( &self, cell: impl FnOnce(&T) -> Option<&TokenRefCell<U, Tk>>, ) -> Option<Result<Ref<'_, U, Tk>, BorrowError>>
Uses borrowed token shared reference to optionally reborrow a TokenRefCell.
Trait Implementations§
Auto Trait Implementations§
impl<'b, T, Tk> Freeze for Ref<'b, T, Tk>
impl<'b, T, Tk> RefUnwindSafe for Ref<'b, T, Tk>
impl<'b, T, Tk> Send for Ref<'b, T, Tk>
impl<'b, T, Tk> Sync for Ref<'b, T, Tk>
impl<'b, T, Tk> Unpin for Ref<'b, T, Tk>
impl<'b, T, Tk> UnwindSafe for Ref<'b, T, Tk>
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