pub struct ArcBorrow<'a, T: ?Sized + 'a>(/* private fields */);
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§
source§impl<'a, T> ArcBorrow<'a, T>
impl<'a, T> ArcBorrow<'a, T>
sourcepub unsafe fn from_ref(r: &'a T) -> Self
pub unsafe fn from_ref(r: &'a T) -> Self
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.
§Safety
- The reference to
T
must have come from a Triomphe Arc, UniqueArc, or ArcBorrow.
sourcepub fn ptr_eq(this: &Self, other: &Self) -> bool
pub fn ptr_eq(this: &Self, other: &Self) -> bool
Compare two ArcBorrow
s via pointer equality. Will only return
true if they come from the same allocation
Trait Implementations§
impl<'a, T> Copy for ArcBorrow<'a, T>
impl<'a, T: Eq + ?Sized + 'a> Eq for ArcBorrow<'a, T>
impl<'a, T: ?Sized + 'a> StructuralPartialEq for ArcBorrow<'a, T>
Auto Trait Implementations§
impl<'a, T> Freeze for ArcBorrow<'a, T>where
T: ?Sized,
impl<'a, T> RefUnwindSafe for ArcBorrow<'a, T>where
T: RefUnwindSafe + ?Sized,
impl<'a, T> Send for ArcBorrow<'a, T>
impl<'a, T> Sync for ArcBorrow<'a, T>
impl<'a, T> Unpin for ArcBorrow<'a, T>where
T: ?Sized,
impl<'a, T> UnwindSafe for ArcBorrow<'a, T>where
T: RefUnwindSafe + ?Sized,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)