pub struct Rc<T> { /* private fields */ }Expand description
A non-atomic reference-counted pointer.
This is similar to std::rc::Rc but with additional features:
- Elision hints from the compiler
- Statistics tracking
- Unique-owner optimization
§Safety
This type is !Send and !Sync — it must only be used on a single thread.
Implementations§
Source§impl<T> Rc<T>
impl<T> Rc<T>
Sourcepub fn strong_count(&self) -> u32
pub fn strong_count(&self) -> u32
Get the current strong reference count.
Sourcepub fn weak_count(&self) -> u32
pub fn weak_count(&self) -> u32
Get the current weak reference count.
Sourcepub fn get_mut(&mut self) -> Option<&mut T>
pub fn get_mut(&mut self) -> Option<&mut T>
Try to get a mutable reference if this is the only strong reference.
Sourcepub fn try_unwrap(self) -> Result<T, Self>
pub fn try_unwrap(self) -> Result<T, Self>
Try to unwrap the value if this is the only reference.
Trait Implementations§
impl<T: Eq> Eq for Rc<T>
Auto Trait Implementations§
impl<T> Freeze for Rc<T>
impl<T> !RefUnwindSafe for Rc<T>
impl<T> !Send for Rc<T>
impl<T> !Sync for Rc<T>
impl<T> Unpin for Rc<T>
impl<T> UnsafeUnpin for Rc<T>
impl<T> !UnwindSafe 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