doc.rust-lang.org
pub fn new(data: T) -> Arc<T>
Constructs a new Arc<T>.
associated_function
alloc
Stable since 1.0.0
Version 1.100.0-nightly
doc.rust-lang.org
pub fn new_cyclic<F>(data_fn: F) -> Arc<T>
Constructs a new Arc<T> while giving you a Weak<T> to the allocation, to allow you to construct a T which holds a weak pointer to itself.
associated_function
alloc
Stable since 1.60.0
Version 1.100.0-nightly
doc.rust-lang.org
pub fn new_uninit() -> Arc<mem::MaybeUninit<T>>
Constructs a new Arc with uninitialized contents.
associated_function
alloc
Stable since 1.82.0
Version 1.100.0-nightly
doc.rust-lang.org
pub fn new_uninit_slice(len: usize) -> Arc<[mem::MaybeUninit<T>]>
Constructs a new atomically reference-counted slice with uninitialized contents.
associated_function
alloc
Stable since 1.82.0
Version 1.100.0-nightly
doc.rust-lang.org
pub fn new_zeroed() -> Arc<mem::MaybeUninit<T>>
Constructs a new Arc with uninitialized contents, with the memory being filled with 0 bytes.
associated_function
alloc
Stable since 1.92.0
Version 1.100.0-nightly
doc.rust-lang.org
pub fn new_zeroed_slice(len: usize) -> Arc<[mem::MaybeUninit<T>]>
Constructs a new atomically reference-counted slice with uninitialized contents, with the memory being filled with 0 bytes.
associated_function
alloc
Stable since 1.92.0
Version 1.100.0-nightly
doc.rust-lang.org
pub fn pin(data: T) -> Pin<Arc<T>>
Constructs a new Pin<Arc<T>>. If T does not implement Unpin, then data will be pinned in memory and unable to be moved.
associated_function
alloc
Stable since 1.33.0
Version 1.100.0-nightly
doc.rust-lang.org
pub fn ptr_eq(this: &Self, other: &Self) -> bool
Returns true if the two Arcs point to the same allocation in a vein similar to ptr::eqptr::eq. This function ignores the metadata of dyn Trait pointers.
associated_function
alloc
Stable since 1.17.0
Version 1.100.0-nightly
doc.rust-lang.org
pub fn strong_count(this: &Self) -> usize
Gets the number of strong (Arc) pointers to this allocation.
associated_function
alloc
Stable since 1.15.0
Version 1.100.0-nightly
doc.rust-lang.org
pub fn try_unwrap(this: Self) -> Result<T, Self>
Returns the inner value, if the Arc has exactly one strong reference.
associated_function
alloc
Stable since 1.4.0
Version 1.100.0-nightly
doc.rust-lang.org
pub fn unwrap_or_clone(this: Self) -> T
If we have the only reference to T then unwrap it. Otherwise, clone T and return the clone.
associated_function
alloc
Stable since 1.76.0
Version 1.100.0-nightly
doc.rust-lang.org
pub fn weak_count(this: &Self) -> usize
Gets the number of Weak pointers to this allocation.
associated_function
alloc
Stable since 1.15.0
Version 1.100.0-nightly
doc.rust-lang.org
pub struct Weak<T, A>
Weak is a version of Arc that holds a non-owning reference to the managed allocation.
struct
alloc
Stable since 1.4.0
Version 1.100.0-nightly
doc.rust-lang.org
pub fn as_ptr(&self) -> *const T
Returns a raw pointer to the object T pointed to by this Weak<T>.
method
alloc
Stable since 1.45.0
Version 1.100.0-nightly
doc.rust-lang.org
pub unsafe fn from_raw(ptr: *const T) -> Self
Converts a raw pointer previously created by into_raw back into Weak<T>.
associated_function
alloc
Stable since 1.45.0
Version 1.100.0-nightly
doc.rust-lang.org
pub fn into_raw(self) -> *const T
Consumes the Weak<T> and turns it into a raw pointer.
method
alloc
Stable since 1.45.0
Version 1.100.0-nightly
doc.rust-lang.org
pub const fn new() -> Weak<T>
Constructs a new Weak<T>, without allocating any memory. Calling upgrade on the return value always gives None.
associated_function
alloc
Stable since 1.10.0
Version 1.100.0-nightly
doc.rust-lang.org
pub fn ptr_eq(&self, other: &Self) -> bool
Returns true if the two Weaks point to the same allocation similar to ptr::eqptr::eq, or if both don't point to any allocation (because they were created with Weak::new()). However, this function ignores the metadata of dyn Trait pointers.
method
alloc
Stable since 1.39.0
Version 1.100.0-nightly
doc.rust-lang.org
pub fn strong_count(&self) -> usize
Gets the number of strong (Arc) pointers pointing to this allocation.
method
alloc
Stable since 1.41.0
Version 1.100.0-nightly
doc.rust-lang.org
pub fn upgrade(&self) -> Option<Arc<T, A>>
Attempts to upgrade the Weak pointer to an Arc, delaying dropping of the inner value if successful.
method
alloc
Stable since 1.4.0
Version 1.100.0-nightly