pub struct Arc<T: ?Sized> { /* private fields */ }
Expand description
A thread-safe reference-counted pointer.
Trait Implementations§
Source§impl<T: ?Sized> Drop for Arc<T>
impl<T: ?Sized> Drop for Arc<T>
Source§fn drop(&mut self)
fn drop(&mut self)
Drops the Arc
.
This will decrement the reference count.
§Examples
use std::sync::Arc;
struct Foo;
impl Drop for Foo {
fn drop(&mut self) {
println!("dropped!");
}
}
let foo = Arc::new(Foo);
let foo2 = Arc::clone(&foo);
drop(foo); // Doesn't print anything
drop(foo2); // Prints "dropped!"
Source§impl<T: ?Sized> IntoMut<T> for Arc<T>
impl<T: ?Sized> IntoMut<T> for Arc<T>
Source§unsafe fn get_mut_unchecked(this: &Self) -> &mut T
unsafe fn get_mut_unchecked(this: &Self) -> &mut T
Obtain a mutable reference to the wrapped value without performing runtime checks for upholding any invariants.
Safety: Calling this is safe if and only if can_make_mut
returns true.
type MutablePointer = UniqueArc<T>
Source§fn can_make_mut(this: &Self) -> bool
fn can_make_mut(this: &Self) -> bool
Check whether converting into a mutable version would succeed.
Source§unsafe fn into_mut_unchecked(this: Self) -> Self::MutablePointer
unsafe fn into_mut_unchecked(this: Self) -> Self::MutablePointer
Convert into a mutable version without performing runtime checks for upholding any
invariants. Read more
Source§fn into_mut(this: Self) -> Result<Self::MutablePointer, Self>
fn into_mut(this: Self) -> Result<Self::MutablePointer, Self>
Try converting into a mutable version of the pointer.
Source§impl<T: ?Sized + Ord> Ord for Arc<T>
impl<T: ?Sized + Ord> Ord for Arc<T>
Source§fn cmp(&self, other: &Arc<T>) -> Ordering
fn cmp(&self, other: &Arc<T>) -> Ordering
Comparison for two Arc
s.
The two are compared by calling cmp()
on their inner values.
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl<T: ?Sized + PartialEq> PartialEq for Arc<T>
impl<T: ?Sized + PartialEq> PartialEq for Arc<T>
Source§impl<T: ?Sized + PartialOrd> PartialOrd for Arc<T>
impl<T: ?Sized + PartialOrd> PartialOrd for Arc<T>
Source§fn partial_cmp(&self, other: &Arc<T>) -> Option<Ordering>
fn partial_cmp(&self, other: &Arc<T>) -> Option<Ordering>
Partial comparison for two Arc
s.
The two are compared by calling partial_cmp()
on their inner values.
Source§fn lt(&self, other: &Arc<T>) -> bool
fn lt(&self, other: &Arc<T>) -> bool
Less-than comparison for two Arc
s.
The two are compared by calling <
on their inner values.
Source§fn le(&self, other: &Arc<T>) -> bool
fn le(&self, other: &Arc<T>) -> bool
‘Less than or equal to’ comparison for two Arc
s.
The two are compared by calling <=
on their inner values.
Source§impl<T: ?Sized> ReferenceCounted<T> for Arc<T>
impl<T: ?Sized> ReferenceCounted<T> for Arc<T>
Source§fn reference_count(this: &Self) -> usize
fn reference_count(this: &Self) -> usize
Get the number of owning pointers referring to the same allocation. Read more
Source§impl<T: ?Sized> SmartPointer<T> for Arc<T>
impl<T: ?Sized> SmartPointer<T> for Arc<T>
impl<T: ?Sized + Eq> Eq for Arc<T>
impl<T: ?Sized + Sync + Send> Send for Arc<T>
impl<T: ?Sized + Sync + Send> Sync for Arc<T>
impl<T: ?Sized> Unpin for Arc<T>
Auto Trait Implementations§
impl<T> Freeze for Arc<T>where
T: ?Sized,
impl<T> RefUnwindSafe for Arc<T>where
T: RefUnwindSafe + ?Sized,
impl<T> UnwindSafe for Arc<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