pub struct LoanCell<T: ?Sized>(/* private fields */);
Expand description
A cell that allows lending a reference to a value for a limited scope.
See the module-level documentation for more information.
Implementations§
Source§impl<T: ?Sized> LoanCell<T>
impl<T: ?Sized> LoanCell<T>
Sourcepub fn lend<R>(&self, value: &T, f: impl FnOnce() -> R) -> R
pub fn lend<R>(&self, value: &T, f: impl FnOnce() -> R) -> R
Lends value
for the lifetime of f
. f
or any function it calls can
access the loaned value via LoanCell::borrow
.
If a value is already lent, it is replaced with value
for the duration
of f
and restored afterwards.
Trait Implementations§
impl<T: RefUnwindSafe + ?Sized> RefUnwindSafe for LoanCell<T>
impl<T: RefUnwindSafe + ?Sized> UnwindSafe for LoanCell<T>
Auto Trait Implementations§
impl<T> !Freeze for LoanCell<T>
impl<T> !Send for LoanCell<T>
impl<T> !Sync for LoanCell<T>
impl<T> Unpin for LoanCell<T>where
T: ?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