Struct stabby::sync::Arc

source ·
#[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,

source

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>

source

pub fn make<F>(constructor: F) -> Arc<T>
where F: FnOnce(&mut MaybeUninit<T>),

Attempts to allocate Self, initializing it with constructor.

Note that the allocation may or may not be zeroed.

§Panics

If the allocator fails to provide an appropriate allocation.

source

pub fn new(value: T) -> Arc<T>

Attempts to allocate Self and store value in it.

§Panics

If the allocator fails to provide an appropriate allocation.

source§

impl<T, Alloc> Arc<T, Alloc>
where Alloc: IAlloc,

source

pub fn try_make_in<F>( constructor: F, alloc: Alloc, ) -> Result<Arc<T, Alloc>, (F, Alloc)>
where F: FnOnce(&mut MaybeUninit<T>),

Attempts to allocate Self, initializing it with constructor.

§Errors

Returns the constructor and the allocator in case of allocation failure.

§Notes

Note that the allocation may or may not be zeroed.

source

pub fn try_new_in(value: T, alloc: Alloc) -> Result<Arc<T, Alloc>, (T, Alloc)>

Attempts to allocate a Self and store value in it

§Errors

Returns value and the allocator in case of failure.

source

pub fn make_in<F>(constructor: F, alloc: Alloc) -> Arc<T, Alloc>
where F: FnOnce(&mut MaybeUninit<T>),

Attempts to allocate Self, initializing it with constructor.

Note that the allocation may or may not be zeroed.

§Panics

If the allocator fails to provide an appropriate allocation.

source

pub fn new_in(value: T, alloc: Alloc) -> Arc<T, Alloc>

Attempts to allocate Self and store value in it.

§Panics

If the allocator fails to provide an appropriate allocation.

source

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.

source

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.

source

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.

source

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.

source

pub fn strong_count(this: &Arc<T, Alloc>) -> usize

Returns the strong count.

source

pub unsafe fn increment_strong_count(this: *const T) -> usize

Increments the strong count.

§Safety

this MUST be a valid pointer derived from Self

source

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.

source

pub fn increment_weak_count(this: &Arc<T, Alloc>) -> usize

Increments the weak count, returning its previous value.

source

pub fn make_mut(&mut self) -> &mut T
where T: Clone, Alloc: Clone,

Returns a mutable reference to this Arc’s value, cloning that value into a new Arc if Self::get_mut would have failed.

source

pub fn is_unique(this: &Arc<T, Alloc>) -> bool

Whether or not this is the sole owner of its data, including weak owners.

source

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.

source

pub fn downgrade(this: &Arc<T, Alloc>) -> Weak<T, Alloc>

Constructs an additional Weak pointer to this.

source

pub const fn allocator(this: &Arc<T, Alloc>) -> &Alloc

Returns a reference to the allocator used to construct this

Trait Implementations§

source§

impl<T, Alloc> Clone for Arc<T, Alloc>
where Alloc: IAlloc,

source§

fn clone(&self) -> Arc<T, Alloc>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<T, Alloc> Deref for Arc<T, Alloc>
where Alloc: IAlloc,

§

type Target = T

The resulting type after dereferencing.
source§

fn deref(&self) -> &<Arc<T, Alloc> as Deref>::Target

Dereferences the value.
source§

impl<T, Alloc> Drop for Arc<T, Alloc>
where Alloc: IAlloc,

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl<T, Alloc> From<&Arc<T, Alloc>> for Weak<T, Alloc>
where Alloc: IAlloc,

source§

fn from(value: &Arc<T, Alloc>) -> Weak<T, Alloc>

Converts to this type from the input type.
source§

impl<T, Alloc> From<Arc<T, Alloc>> for ArcSlice<T, Alloc>
where Alloc: IAlloc,

source§

fn from(value: Arc<T, Alloc>) -> ArcSlice<T, Alloc>

Converts to this type from the input type.
source§

impl<T, Alloc> IPtr for Arc<T, Alloc>
where Alloc: IAlloc,

source§

unsafe fn as_ref<U>(&self) -> &U

Safety Read more
source§

impl<T, Alloc> IPtrClone for Arc<T, Alloc>
where Alloc: IAlloc,

source§

fn clone(this: &Arc<T, Alloc>) -> Arc<T, Alloc>

Clone the pointer.
source§

impl<T, Alloc> IPtrOwned for Arc<T, Alloc>
where Alloc: IAlloc,

source§

fn drop( this: &mut ManuallyDrop<Arc<T, Alloc>>, drop: unsafe extern "C" fn(_: &mut ()), )

Called instead of Drop::drop when the dynptr is dropped.
source§

impl<T, Alloc> IPtrTryAsMut for Arc<T, Alloc>
where Alloc: IAlloc,

source§

unsafe fn try_as_mut<U>(&mut self) -> Option<&mut U>

Safety Read more
source§

impl<T, Alloc> IStable for Arc<T, Alloc>
where Alloc: IAlloc, Struct<AllocPtr<T, Alloc>>: IStable, AllocPtr<T, Alloc>: IStable,

§

type ForbiddenValues = <Struct<AllocPtr<T, Alloc>> as IStable>::ForbiddenValues

The values that the annotated type cannot occupy.
§

type UnusedBits = <Struct<AllocPtr<T, Alloc>> as IStable>::UnusedBits

The padding bits in the annotated types
§

type Size = <Struct<AllocPtr<T, Alloc>> as IStable>::Size

The size of the annotated type in bytes.
§

type Align = <Struct<AllocPtr<T, Alloc>> as IStable>::Align

The alignment of the annotated type in bytes.
§

type HasExactlyOneNiche = <Struct<AllocPtr<T, Alloc>> as IStable>::HasExactlyOneNiche

Allows the detection of whether or not core::option::Options are stable: Read more
§

type ContainsIndirections = <Struct<AllocPtr<T, Alloc>> as IStable>::ContainsIndirections

Whether or not the type contains indirections (pointers, indices in independent data-structures…)
source§

const REPORT: &'static TypeReport = _

A compile-time generated report of the fields of the type, allowing for compatibility inspection.
source§

const ID: u64 = _

A stable (and ideally unique) identifier for the type. Often generated using crate::report::gen_id, but can be manually set.
source§

fn size() -> usize

Returns the size of the type.
source§

fn align() -> usize

Returns the alignment of the type.
source§

impl<T, Alloc> IntoDyn for Arc<T, Alloc>
where Alloc: IAlloc,

§

type Anonymized = Arc<(), Alloc>

A pointer type with type information discarded.
§

type Target = T

The original pointee.
source§

fn anonimize(self) -> <Arc<T, Alloc> as IntoDyn>::Anonymized

Drop the type information from the pointer.
source§

impl<T, Alloc> Send for Arc<T, Alloc>
where T: Send + Sync, Alloc: IAlloc + Send + Sync,

source§

impl<T, Alloc> Sync for Arc<T, Alloc>
where T: Send + Sync, Alloc: IAlloc + Send + Sync,

Auto Trait Implementations§

§

impl<T, Alloc> Freeze for Arc<T, Alloc>

§

impl<T, Alloc> RefUnwindSafe for Arc<T, Alloc>
where Alloc: RefUnwindSafe, T: RefUnwindSafe,

§

impl<T, Alloc> Unpin for Arc<T, Alloc>

§

impl<T, Alloc> UnwindSafe for Arc<T, Alloc>
where T: RefUnwindSafe, Alloc: UnwindSafe,

Blanket Implementations§

source§

impl<Source> AccessAs for Source

source§

fn ref_as<T>(&self) -> <Source as IGuardRef<T>>::Guard<'_>
where Source: IGuardRef<T>, T: ?Sized,

Provides immutable access to a type as if it were its ABI-unstable equivalent.
source§

fn mut_as<T>(&mut self) -> <Source as IGuardMut<T>>::GuardMut<'_>
where Source: IGuardMut<T>, T: ?Sized,

Provides mutable access to a type as if it were its ABI-unstable equivalent.
source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Any for T
where T: IStable,

source§

extern "C" fn report(&self) -> &'static TypeReport

The report of the type.
source§

extern "C" fn id(&self) -> u64

The id of the type.
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, As> IGuardMut<As> for T
where T: Into<As>, As: Into<T>,

§

type GuardMut<'a> = MutAs<'a, T, As> where T: 'a

The type of the guard which will clean up the temporary after applying its changes to the original.
source§

fn guard_mut_inner(&mut self) -> <T as IGuardMut<As>>::GuardMut<'_>

Construct the temporary and guard it through a mutable reference.
source§

impl<T, As> IGuardRef<As> for T
where T: Into<As>, As: Into<T>,

§

type Guard<'a> = RefAs<'a, T, As> where T: 'a

The type of the guard which will clean up the temporary.
source§

fn guard_ref_inner(&self) -> <T as IGuardRef<As>>::Guard<'_>

Construct the temporary and guard it through an immutable reference.
source§

impl<T> Includes<End> for T

§

type Output = End

The result
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.