pub struct Ref<'a, T> { /* private fields */ }Expand description
A borrowed handle: a view of an object owned by something else.
The C ABI hands out interior pointers for struct fields and vector
elements (&self->field, &self->vec[i]). Those must never be freed,
so they cannot be represented by the owning handle types, which all
implement Drop. Ref wraps one in ManuallyDrop and ties it to the
parent’s lifetime, so it neither frees nor outlives its owner.
Derefs to the underlying type, so it is used exactly like &T.
Trait Implementations§
Auto Trait Implementations§
impl<'a, T> Freeze for Ref<'a, T>where
T: Freeze,
impl<'a, T> RefUnwindSafe for Ref<'a, T>where
T: RefUnwindSafe,
impl<'a, T> Send for Ref<'a, T>
impl<'a, T> Sync for Ref<'a, T>where
T: Sync,
impl<'a, T> Unpin for Ref<'a, T>where
T: Unpin,
impl<'a, T> UnsafeUnpin for Ref<'a, T>where
T: UnsafeUnpin,
impl<'a, T> UnwindSafe for Ref<'a, T>where
T: UnwindSafe + RefUnwindSafe,
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
Mutably borrows from an owned value. Read more