[][src]Struct triomphe::ArcBorrow

pub struct ArcBorrow<'a, T: 'a>(_);

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.

Methods

impl<'a, T> ArcBorrow<'a, T>[src]

pub fn clone_arc(&self) -> Arc<T>[src]

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

pub unsafe fn from_ref(r: &'a T) -> Self[src]

For constructing from a reference known to be Arc-backed, e.g. if we obtain such a reference over FFI

pub fn ptr_eq(this: &Self, other: &Self) -> bool[src]

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

pub fn with_arc<F, U>(&self, f: F) -> U where
    F: FnOnce(&Arc<T>) -> U,
    T: 'static, 
[src]

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

pub fn get(&self) -> &'a T[src]

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

impl<'a, T> Clone for ArcBorrow<'a, T>[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl<'a, T: Eq + 'a> Eq for ArcBorrow<'a, T>[src]

impl<'a, T> Copy for ArcBorrow<'a, T>[src]

impl<'a, T: PartialEq + 'a> PartialEq<ArcBorrow<'a, T>> for ArcBorrow<'a, T>[src]

impl<'a, T> Deref for ArcBorrow<'a, T>[src]

type Target = T

The resulting type after dereferencing.

impl<'a, T: Debug + 'a> Debug for ArcBorrow<'a, T>[src]

Auto Trait Implementations

impl<'a, T> Send for ArcBorrow<'a, T> where
    T: Sync

impl<'a, T> Sync for ArcBorrow<'a, T> where
    T: Sync

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]