pub struct Rc<T: ?Sized> { /* private fields */ }
Expand description
A reference-counted pointer. ‘Rc’ stands for ‘Reference Counted’.
This may or may not use atomic access for the reference count, depending on whether it is ever
converted to an Arc
.
Implementations§
Source§impl<T> Rc<T>
impl<T> Rc<T>
Sourcepub fn new(data: T) -> Self
pub fn new(data: T) -> Self
Constructs a new Rc<T>
.
This is initially single-threaded, so updates to the reference count will use non-atomic
access. If an Arc
is ever created from this instance, this will cause all of its
references to start using atomic access to the reference count.
Sourcepub fn from_arc(arc: Arc<T>) -> Self
pub fn from_arc(arc: Arc<T>) -> Self
Converts an Arc<T>
to Rc<T>
. This does not change its atomic property.
Attempts to convert this to an unsynchronized pointer, no longer atomic. Returns true
if
successful, or false
if there are still potentially references on other threads.
Trait Implementations§
Source§impl<T: ?Sized + Ord> Ord for Rc<T>
impl<T: ?Sized + Ord> Ord for Rc<T>
Source§impl<T: ?Sized + PartialOrd> PartialOrd for Rc<T>
impl<T: ?Sized + PartialOrd> PartialOrd for Rc<T>
impl<T: ?Sized + Eq> Eq for Rc<T>
impl<T: RefUnwindSafe + ?Sized> UnwindSafe for Rc<T>
Auto Trait Implementations§
impl<T> Freeze for Rc<T>where
T: ?Sized,
impl<T> !RefUnwindSafe for Rc<T>
impl<T> !Send for Rc<T>
impl<T> !Sync for Rc<T>
impl<T> Unpin for Rc<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