Struct corundum::cell::Ref [−][src]
Implementations
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
.
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
Auto Trait Implementations
impl<'b, T, A> LooseTxInUnsafe for Ref<'b, T, A> where
T: LooseTxInUnsafe,
impl<'b, T: ?Sized, A> RefUnwindSafe for Ref<'b, T, A> where
T: RefUnwindSafe,
impl<'b, T: ?Sized, A> UnwindSafe for Ref<'b, T, A> where
T: RefUnwindSafe,