#[repr(transparent)]
pub struct ArcBorrow<'a, T: ?Sized + 'a>(_);
Expand description

A “borrowed Arc”. This is a pointer to a T that is known to have been allocated within an Arc.

This is equivalent in guarantees to &Arc<T>, however it is a bit more flexible. To obtain an &Arc<T> you must have an Arc<T> instance somewhere pinned down until we’re done with it. It’s also a direct pointer to T, so using this involves less pointer-chasing

However, C++ code may hand us refcounted things as pointers to T directly, so we have to conjure up a temporary Arc on the stack each time. The same happens for when the object is managed by a OffsetArc.

ArcBorrow lets us deal with borrows of known-refcounted objects without needing to worry about where the Arc<T> is.

Implementations

Clone this as an Arc<T>. This bumps the refcount.

For constructing from a reference known to be Arc-backed, e.g. if we obtain such a reference over FFI TODO: should from_ref be relaxed to unsized types? It can’t be converted back to an Arc right now for unsized types.

Compare two ArcBorrows via pointer equality. Will only return true if they come from the same allocation

Temporarily converts |self| into a bonafide Arc and exposes it to the provided callback. The refcount is not modified.

Similar to deref, but uses the lifetime |a| rather than the lifetime of self, which is incompatible with the signature of the Deref trait.

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
The resulting type after dereferencing.
Dereferences the value.
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.