Struct Arc

Source
pub struct Arc<T: ?Sized, Owner: ?Sized = dyn Destruct + Send + Sync> { /* private fields */ }
Expand description

A projecting version of Arc which allows owning a containing struct but referencing a field.

Implementations§

Source§

impl<'a, T: 'a + Send + Sync> Arc<T, dyn Destruct + Send + Sync + 'a>

Source

pub fn new(this: T) -> Self

Constructs a new Arc<T> with erased owner.

Source§

impl<T> Arc<T, T>

Source

pub fn new_owner(this: T) -> Self

Constructs a new Arc<T, T> with typed owner.

Source§

impl<'a, T: ?Sized, Owner: 'a + Send + Sync> Arc<T, Owner>

Source

pub fn erase_owner(this: Self) -> Arc<T, dyn Destruct + Send + Sync + 'a>

Erases the owning type so projected Arc<T> can be used uniformly.

Source§

impl<T: ?Sized, Owner: ?Sized> Arc<T, Owner>

Source

pub fn as_ptr(this: &Self) -> *const T

Provides a raw pointer to the data.

Source

pub fn downgrade(this: &Self) -> Weak<T, Owner>

Creates a new Weak pointer to this projected field.

Source

pub fn owner(this: &Self) -> Arc<Owner>

Gets a reference to the owning allocation.

This returns a clone of the owning Arc, so it cannot return a unique reference. If you want to take unique ownership, use into_owner instead.

Source

pub fn into_owner(this: Self) -> Arc<Owner>

Consumes this projected field and returns the owning allocation.

Source

pub fn project<U: ?Sized>( this: Self, projection: impl FnOnce(&T) -> &U, ) -> Arc<U, Owner>

Projects this allocation to a field.

Note that the projected field is not required to actually be owned by the owner; it could be any longer-lived reference.

Source

pub fn ptr_eq(lhs: &Self, rhs: &Self) -> bool

Returns true if the two Arcs point to the same field in the same allocated object.

See ptr::eq for the caveats when comparing dyn Trait pointers, which this does when the owner type is erased.

Source§

impl<T: ?Sized, Owner: ?Sized> Arc<T, Owner>

Source

pub fn unsize<U: ?Sized, F>( this: Self, with: Coercion<T, U, F>, ) -> Arc<U, Owner>
where T: Sized, F: FnOnce(*const T) -> *const U,

Available on crate feature unsize only.

Convert this pointer with an unsizing coercion (e.g. from T to dyn Trait or [T; N] to [T]).

Source

pub fn unsize_owner<Pwner: ?Sized, F>( this: Self, with: Coercion<Owner, Pwner, F>, ) -> Arc<T, Pwner>
where Owner: Sized, F: FnOnce(*const Owner) -> *const Pwner,

Available on crate feature unsize only.

Convert this pointer with an unsizing coercion of the owner (e.g. from T to dyn Trait or [T; N] to [T]).

Trait Implementations§

Source§

impl<T: ?Sized, Owner: ?Sized> AsRef<T> for Arc<T, Owner>

Source§

fn as_ref(&self) -> &T

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<T: ?Sized, Owner: ?Sized> Borrow<T> for Arc<T, Owner>

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T: ?Sized, Owner: ?Sized> Clone for Arc<T, Owner>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<T, U: ?Sized, Owner: ?Sized> CoerciblePtr<U> for Arc<T, Owner>

Available on crate feature unsize only.
Source§

type Pointee = T

The type we point to. This influences which kinds of unsizing are possible.
Source§

type Output = Arc<U, Owner>

The output type when unsizing the pointee to U.
Source§

fn as_sized_ptr(&mut self) -> *mut Self::Pointee

Get the raw inner pointer.
Source§

unsafe fn replace_ptr(self, ptr: *mut U) -> Self::Output

Replace the container inner pointer with an unsized version. Read more
Source§

impl<T, Owner: ?Sized> Debug for Arc<T, Owner>
where T: Debug + ?Sized,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: Default> Default for Arc<T, T>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'a, T: 'a + Default> Default for Arc<T, dyn Destruct + 'a>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'a, T: 'a + Default + Send> Default for Arc<T, dyn Destruct + Send + 'a>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'a, T: 'a + Default + Send + Sync> Default for Arc<T, dyn Destruct + Send + Sync + 'a>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<T: ?Sized, Owner: ?Sized> Deref for Arc<T, Owner>

Source§

type Target = T

The resulting type after dereferencing.
Source§

fn deref(&self) -> &T

Dereferences the value.
Source§

impl<T, Owner: ?Sized> Display for Arc<T, Owner>
where T: Display + ?Sized,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T, Owner: ?Sized> Error for Arc<T, Owner>
where T: Error + ?Sized,

Available on crate feature std only.
Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0: use the Display impl or to_string()
1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0: replaced by Error::source, which can support downcasting
Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl<T: ?Sized> From<Arc<T>> for Arc<T, T>

Source§

fn from(owner: Arc<T>) -> Self

Converts to this type from the input type.
Source§

impl<T: ?Sized, Owner: ?Sized> From<Arc<T, Owner>> for Arc<Owner>

Source§

fn from(this: Arc<T, Owner>) -> Self

Converts to this type from the input type.
Source§

impl<'a, T: ?Sized, Owner: 'a> From<Arc<T, Owner>> for Arc<T, dyn Destruct + 'a>

Source§

fn from(this: Arc<T, Owner>) -> Self

Converts to this type from the input type.
Source§

impl<'a, T: ?Sized, Owner: 'a + Send> From<Arc<T, Owner>> for Arc<T, dyn Destruct + Send + 'a>

Source§

fn from(this: Arc<T, Owner>) -> Self

Converts to this type from the input type.
Source§

impl<'a, T: ?Sized, Owner: 'a + Send + Sync> From<Arc<T, Owner>> for Arc<T, dyn Destruct + Send + Sync + 'a>

Source§

fn from(this: Arc<T, Owner>) -> Self

Converts to this type from the input type.
Source§

impl<T, Owner: ?Sized> From<T> for Arc<T, Owner>
where Arc<T, Owner>: From<Arc<T, T>>,

Source§

fn from(this: T) -> Self

Converts to this type from the input type.
Source§

impl<T, Owner: ?Sized> Hash for Arc<T, Owner>
where T: Hash + ?Sized,

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<T, Owner: ?Sized> Ord for Arc<T, Owner>
where T: Ord + ?Sized,

Source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl<T, Owner: ?Sized> PartialEq for Arc<T, Owner>
where T: PartialEq + ?Sized,

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T, Owner: ?Sized> PartialOrd for Arc<T, Owner>
where T: PartialOrd + ?Sized,

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<T: ?Sized, Owner: ?Sized> Pointer for Arc<T, Owner>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T, Owner: ?Sized> Eq for Arc<T, Owner>
where T: Eq + ?Sized,

Source§

impl<T: ?Sized, Owner: ?Sized> Send for Arc<T, Owner>
where for<'a> &'a T: Send, Arc<Owner>: Send,

Source§

impl<T: ?Sized, Owner: ?Sized> Sync for Arc<T, Owner>
where for<'a> &'a T: Sync, Arc<Owner>: Sync,

Source§

impl<T: ?Sized, Owner: ?Sized> UnwindSafe for Arc<T, Owner>
where for<'a> &'a T: UnwindSafe, Arc<Owner>: UnwindSafe,

Available on crate feature std only.

Auto Trait Implementations§

§

impl<T, Owner> Freeze for Arc<T, Owner>
where T: ?Sized, Owner: ?Sized,

§

impl<T, Owner> RefUnwindSafe for Arc<T, Owner>
where T: RefUnwindSafe + ?Sized, Owner: RefUnwindSafe + ?Sized,

§

impl<T, Owner> Unpin for Arc<T, Owner>
where T: ?Sized, Owner: ?Sized,

Blanket Implementations§

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> 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T, U> CoerceUnsize<U> for T
where T: CoerciblePtr<U>, U: ?Sized,

Source§

fn unsize<F>(self, with: Coercion<Self::Pointee, U, F>) -> Self::Output
where F: FnOnce(*const Self::Pointee) -> *const U,

Convert a pointer, as if with unsize coercion. Read more
Source§

impl<T> From<!> for T

Source§

fn from(t: !) -> T

Converts to this type from the input type.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

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

Source§

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

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

Source§

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>,

Source§

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.
Source§

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