Implementations
sourceimpl<'b, T: PSafe + ?Sized, A: MemPool> Ref<'b, T, A>
impl<'b, T: PSafe + ?Sized, A: MemPool> Ref<'b, T, A>
sourcepub fn clone(orig: &Ref<'b, T, A>) -> Ref<'b, T, A>
pub fn clone(orig: &Ref<'b, T, A>) -> Ref<'b, T, A>
Copies a Ref
.
The PRefCell
is already immutably borrowed, so this cannot fail. To
be able to borrow mutably, all Ref
s should go out of scope.
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 r.borrow().clone()
to clone the contents of
a PRefCell
.
sourcepub fn leak(orig: Ref<'b, T, A>) -> &'b T
pub fn leak(orig: Ref<'b, T, A>) -> &'b T
Convert into a reference to the underlying data.
The underlying RefCell
can never be mutably borrowed from again and will always appear
already immutably borrowed. It is not a good idea to leak more than a constant number of
references. The RefCell
can be immutably borrowed again if only a smaller number of leaks
have occurred in total.
This is an associated function that needs to be used as
Ref::leak(...)
. A method would interfere with methods of the
same name on the contents of a RefCell
used through Deref
.
Examples
#![feature(cell_leak)]
use std::cell::{RefCell, Ref};
let cell = RefCell::new(0);
let value = Ref::leak(cell.borrow());
assert_eq!(*value, 0);
assert!(cell.try_borrow().is_ok());
assert!(cell.try_borrow_mut().is_err());
Trait Implementations
impl<T: ?Sized, A: MemPool> !Send for Ref<'_, T, A>
impl<T: ?Sized, A: MemPool> !Sync for Ref<'_, T, A>
impl<T: ?Sized, A: MemPool> !TxOutSafe for Ref<'_, T, A>
Auto Trait Implementations
impl<'b, T, A> LooseTxInUnsafe for Ref<'b, T, A> where
T: LooseTxInUnsafe,
impl<'b, T, A> !PSafe for Ref<'b, T, A>
impl<'b, T, A> !PSend for Ref<'b, T, A>
impl<'b, T: ?Sized, A> RefUnwindSafe for Ref<'b, T, A> where
T: RefUnwindSafe,
impl<'b, T: ?Sized, A> TxInSafe for Ref<'b, T, A> where
T: TxInSafe,
impl<'b, T: ?Sized, A> Unpin for Ref<'b, T, A>
impl<'b, T: ?Sized, A> UnwindSafe for Ref<'b, T, A> where
T: RefUnwindSafe,
impl<'b, T: ?Sized, A> VSafe for Ref<'b, T, A>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more