pub struct Ref<'a, T: ?Sized> { /* private fields */ }
Expand description
An immutable reference, like &T
.
Internally, the reference is stored as a pointer to avoid provenance narrowing.
Implementations
sourceimpl<'a, T: ?Sized> Ref<'a, T>
impl<'a, T: ?Sized> Ref<'a, T>
sourcepub unsafe fn new_unchecked(ptr: *const T) -> Self
pub unsafe fn new_unchecked(ptr: *const T) -> Self
Creates a new Ref
from a shared pointer.
Safety
ptr
must be non-null, properly aligned, and valid for reads.ptr
must not alias any other mutable references for'a
.- The value pointed to by
ptr
must be initialized.
Trait Implementations
sourceimpl<'a, T: ?Sized> Destructure for Ref<'a, T>
impl<'a, T: ?Sized> Destructure for Ref<'a, T>
type Underlying = T
type Underlying = T
The underlying type that is destructured.
type Destructuring = Ref
type Destructuring = Ref
The type of destructuring to perform.
sourcefn underlying(&mut self) -> *mut Self::Underlying
fn underlying(&mut self) -> *mut Self::Underlying
Returns a mutable pointer to the underlying type.
sourceimpl<T: DisplayRaw + ?Sized> Display for Ref<'_, T>
impl<T: DisplayRaw + ?Sized> Display for Ref<'_, T>
sourceimpl<'a, T, U: 'a> Restructure<U> for Ref<'a, T>
impl<'a, T, U: 'a> Restructure<U> for Ref<'a, T>
type Restructured = Ref<'a, U>
type Restructured = Ref<'a, U>
The restructured version of this type.
sourceunsafe fn restructure(&self, ptr: *mut U) -> Self::Restructured
unsafe fn restructure(&self, ptr: *mut U) -> Self::Restructured
Restructures a pointer to this type into the target type. Read more
impl<'a, T: ?Sized> Copy for Ref<'a, T>
impl<T: ?Sized> RestructurablePointer for Ref<'_, T>
impl<T: Unique + ?Sized> Singleton for Ref<'_, T>
impl<T: Pinned<R> + ?Sized, R: Region> Within<R> for Ref<'_, T>
Auto Trait Implementations
impl<'a, T: ?Sized> RefUnwindSafe for Ref<'a, T>where
T: RefUnwindSafe,
impl<'a, T> !Send for Ref<'a, T>
impl<'a, T> !Sync for Ref<'a, T>
impl<'a, T: ?Sized> Unpin for Ref<'a, T>
impl<'a, T: ?Sized> UnwindSafe for Ref<'a, T>where
T: RefUnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more