#[repr(C)]pub struct Arc<T, Alloc = LibcAlloc>where
Alloc: IAlloc,{ /* private fields */ }
Expand description
alloc::sync::Arc
, but ABI-stable.
Implementations§
source§impl<T, Alloc> Arc<T, Alloc>where
Alloc: IAlloc,
impl<T, Alloc> Arc<T, Alloc>where
Alloc: IAlloc,
sourcepub const fn has_optimal_layout() -> bool
pub const fn has_optimal_layout() -> bool
Returns true if the layout for Arc
is smaller or equal to that Rust would have generated for it.
source§impl<T> Arc<T>
impl<T> Arc<T>
sourcepub fn make<F>(constructor: F) -> Arc<T>where
F: FnOnce(&mut MaybeUninit<T>),
pub fn make<F>(constructor: F) -> Arc<T>where
F: FnOnce(&mut MaybeUninit<T>),
source§impl<T, Alloc> Arc<T, Alloc>where
Alloc: IAlloc,
impl<T, Alloc> Arc<T, Alloc>where
Alloc: IAlloc,
sourcepub fn try_make_in<F>(
constructor: F,
alloc: Alloc,
) -> Result<Arc<T, Alloc>, (F, Alloc)>where
F: FnOnce(&mut MaybeUninit<T>),
pub fn try_make_in<F>(
constructor: F,
alloc: Alloc,
) -> Result<Arc<T, Alloc>, (F, Alloc)>where
F: FnOnce(&mut MaybeUninit<T>),
sourcepub fn try_new_in(value: T, alloc: Alloc) -> Result<Arc<T, Alloc>, (T, Alloc)>
pub fn try_new_in(value: T, alloc: Alloc) -> Result<Arc<T, Alloc>, (T, Alloc)>
sourcepub fn make_in<F>(constructor: F, alloc: Alloc) -> Arc<T, Alloc>where
F: FnOnce(&mut MaybeUninit<T>),
pub fn make_in<F>(constructor: F, alloc: Alloc) -> Arc<T, Alloc>where
F: FnOnce(&mut MaybeUninit<T>),
sourcepub const fn into_raw(this: Arc<T, Alloc>) -> AllocPtr<T, Alloc>
pub const fn into_raw(this: Arc<T, Alloc>) -> AllocPtr<T, Alloc>
Returns the pointer to the inner raw allocation, leaking this
.
Note that the pointer may be dangling if T
is zero-sized.
sourcepub const unsafe fn from_raw(this: AllocPtr<T, Alloc>) -> Arc<T, Alloc>
pub const unsafe fn from_raw(this: AllocPtr<T, Alloc>) -> Arc<T, Alloc>
Constructs Self
from a raw allocation.
§Safety
this
MUST not be dangling, and have been obtained through Self::into_raw
.
sourcepub fn get_mut(this: &mut Arc<T, Alloc>) -> Option<&mut T>
pub fn get_mut(this: &mut Arc<T, Alloc>) -> Option<&mut T>
Provides a mutable reference to the internals if the strong and weak counts are both 1.
sourcepub unsafe fn get_mut_unchecked(this: &mut Arc<T, Alloc>) -> &mut T
pub unsafe fn get_mut_unchecked(this: &mut Arc<T, Alloc>) -> &mut T
Provides a mutable reference to the internals without checking.
§Safety
If used carelessly, this can cause mutable references and immutable references to the same value to appear, causing undefined behaviour.
sourcepub fn strong_count(this: &Arc<T, Alloc>) -> usize
pub fn strong_count(this: &Arc<T, Alloc>) -> usize
Returns the strong count.
sourcepub unsafe fn increment_strong_count(this: *const T) -> usize
pub unsafe fn increment_strong_count(this: *const T) -> usize
sourcepub fn weak_count(this: &Arc<T, Alloc>) -> usize
pub fn weak_count(this: &Arc<T, Alloc>) -> usize
Returns the weak count. Note that all Arcs to a same value share a Weak, so the weak count can never be 0.
sourcepub fn increment_weak_count(this: &Arc<T, Alloc>) -> usize
pub fn increment_weak_count(this: &Arc<T, Alloc>) -> usize
Increments the weak count, returning its previous value.
sourcepub fn make_mut(&mut self) -> &mut T
pub fn make_mut(&mut self) -> &mut T
Returns a mutable reference to this Arc
’s value, cloning that value into a new Arc
if Self::get_mut
would have failed.
sourcepub fn is_unique(this: &Arc<T, Alloc>) -> bool
pub fn is_unique(this: &Arc<T, Alloc>) -> bool
Whether or not this
is the sole owner of its data, including weak owners.
sourcepub fn try_into_inner(this: Arc<T, Alloc>) -> Result<T, Arc<T, Alloc>>
pub fn try_into_inner(this: Arc<T, Alloc>) -> Result<T, Arc<T, Alloc>>
Attempts the value from the allocation, freeing said allocation.
§Errors
Returns this
if it’s not the sole owner of its value.
Trait Implementations§
source§impl<T, Alloc> IPtrTryAsMut for Arc<T, Alloc>where
Alloc: IAlloc,
impl<T, Alloc> IPtrTryAsMut for Arc<T, Alloc>where
Alloc: IAlloc,
source§impl<T, Alloc> IStable for Arc<T, Alloc>
impl<T, Alloc> IStable for Arc<T, Alloc>
§type ForbiddenValues = <Struct<AllocPtr<T, Alloc>> as IStable>::ForbiddenValues
type ForbiddenValues = <Struct<AllocPtr<T, Alloc>> as IStable>::ForbiddenValues
§type UnusedBits = <Struct<AllocPtr<T, Alloc>> as IStable>::UnusedBits
type UnusedBits = <Struct<AllocPtr<T, Alloc>> as IStable>::UnusedBits
§type Align = <Struct<AllocPtr<T, Alloc>> as IStable>::Align
type Align = <Struct<AllocPtr<T, Alloc>> as IStable>::Align
§type HasExactlyOneNiche = <Struct<AllocPtr<T, Alloc>> as IStable>::HasExactlyOneNiche
type HasExactlyOneNiche = <Struct<AllocPtr<T, Alloc>> as IStable>::HasExactlyOneNiche
core::option::Option
s are stable: Read more§type ContainsIndirections = <Struct<AllocPtr<T, Alloc>> as IStable>::ContainsIndirections
type ContainsIndirections = <Struct<AllocPtr<T, Alloc>> as IStable>::ContainsIndirections
source§const REPORT: &'static TypeReport = _
const REPORT: &'static TypeReport = _
source§const ID: u64 = _
const ID: u64 = _
crate::report::gen_id
, but can be manually set.