Struct fallacy_arc::Arc
source · [−]#[repr(transparent)]pub struct Arc<T: ?Sized>(_);Expand description
A thread-safe reference-counting pointer. ‘Arc’ stands for ‘Atomically Reference Counted’.
The type Arc<T> provides shared ownership cod
of a value of type T,
allocated in the heap. Invoking clone on Arc produces
a new Arc instance, which points to the same allocation on the heap as the
source Arc, while increasing a reference count. When the last Arc
pointer to a given allocation is destroyed, the value stored in that allocation (often
referred to as “inner value”) is also dropped.
Implementations
sourceimpl<T> Arc<T>
impl<T> Arc<T>
sourcepub fn try_new(data: T) -> Result<Arc<T>, AllocError>
pub fn try_new(data: T) -> Result<Arc<T>, AllocError>
Constructs a new Arc<T>, returning an error if allocation fails.
sourceimpl<T: ?Sized> Arc<T>
impl<T: ?Sized> Arc<T>
pub fn into_std(self) -> StdArc<T>
pub fn from_std(a: StdArc<T>) -> Self
sourcepub fn weak_count(this: &Self) -> usize
pub fn weak_count(this: &Self) -> usize
sourcepub fn strong_count(this: &Self) -> usize
pub fn strong_count(this: &Self) -> usize
Gets the number of strong (Arc) pointers to this allocation.
Safety
This method by itself is safe, but using it correctly requires extra care. Another thread can change the strong count at any time, including potentially between calling this method and acting on the result.
Trait Implementations
sourceimpl<T: Ord + ?Sized> Ord for Arc<T>
impl<T: Ord + ?Sized> Ord for Arc<T>
sourceimpl<T: PartialOrd + ?Sized> PartialOrd<Arc<T>> for Arc<T>
impl<T: PartialOrd + ?Sized> PartialOrd<Arc<T>> for Arc<T>
sourcefn partial_cmp(&self, other: &Arc<T>) -> Option<Ordering>
fn partial_cmp(&self, other: &Arc<T>) -> Option<Ordering>
This method returns an ordering between self and other values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self and other) and is used by the <=
operator. Read more
impl<T: Eq + ?Sized> Eq for Arc<T>
impl<T: ?Sized> StructuralEq for Arc<T>
impl<T: ?Sized> StructuralPartialEq for Arc<T>
Auto Trait Implementations
impl<T: ?Sized> RefUnwindSafe for Arc<T> where
T: RefUnwindSafe,
impl<T: ?Sized> Send for Arc<T> where
T: Send + Sync,
impl<T: ?Sized> Sync for Arc<T> where
T: Send + Sync,
impl<T: ?Sized> Unpin for Arc<T>
impl<T: ?Sized> UnwindSafe for Arc<T> where
T: RefUnwindSafe,
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
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into)Uses borrowed data to replace owned data, usually by cloning. Read more