pub struct NonNullConst<T>(/* private fields */)
where
T: ?Sized;Expand description
A wrapper around NonNull that is explicitly a const pointer.
Implementations§
Source§impl<T> NonNullConst<T>where
T: ?Sized,
impl<T> NonNullConst<T>where
T: ?Sized,
Sourcepub const fn into_nonnull(self) -> NonNull<T>
pub const fn into_nonnull(self) -> NonNull<T>
Convert into a plain NonNull.
Sourcepub const fn as_nonnull(&self) -> &NonNull<T>
pub const fn as_nonnull(&self) -> &NonNull<T>
Take a reference to the internal NonNull.
Sourcepub const unsafe fn new_unchecked(ptr: *const T) -> Self
pub const unsafe fn new_unchecked(ptr: *const T) -> Self
Sourcepub unsafe fn as_ref<'a>(&self) -> &'a T
pub unsafe fn as_ref<'a>(&self) -> &'a T
Returns a shared reference to the value.
§Safety
When calling this method, you have to ensure that the pointer is convertible to a reference.
Sourcepub const fn cast<U>(self) -> NonNullConst<U>
pub const fn cast<U>(self) -> NonNullConst<U>
Casts to a pointer of another type.
Source§impl NonNullConst<c_void>
impl NonNullConst<c_void>
Sourcepub const unsafe fn new_void_unchecked<U>(ptr: *const U) -> Selfwhere
U: ?Sized,
pub const unsafe fn new_void_unchecked<U>(ptr: *const U) -> Selfwhere
U: ?Sized,
Creates a new NonNullConst, casting the passsed pointer to void
pointer.
§Safety
ptr must be non-null.
Trait Implementations§
Source§impl<T> Clone for NonNullConst<T>where
T: ?Sized,
impl<T> Clone for NonNullConst<T>where
T: ?Sized,
Source§impl<T> Debug for NonNullConst<T>where
T: ?Sized,
impl<T> Debug for NonNullConst<T>where
T: ?Sized,
Source§impl<T> Hash for NonNullConst<T>where
T: ?Sized,
impl<T> Hash for NonNullConst<T>where
T: ?Sized,
Source§impl<T> Ord for NonNullConst<T>where
T: ?Sized,
impl<T> Ord for NonNullConst<T>where
T: ?Sized,
Source§impl<T> PartialEq for NonNullConst<T>where
T: ?Sized,
impl<T> PartialEq for NonNullConst<T>where
T: ?Sized,
Source§impl<T> PartialOrd for NonNullConst<T>where
T: ?Sized,
impl<T> PartialOrd for NonNullConst<T>where
T: ?Sized,
Source§impl<T> Pointer for NonNullConst<T>where
T: ?Sized,
impl<T> Pointer for NonNullConst<T>where
T: ?Sized,
impl<T> Copy for NonNullConst<T>where
T: ?Sized,
impl<T> Eq for NonNullConst<T>where
T: ?Sized,
Auto Trait Implementations§
impl<T> Freeze for NonNullConst<T>where
T: ?Sized,
impl<T> RefUnwindSafe for NonNullConst<T>where
T: RefUnwindSafe + ?Sized,
impl<T> !Send for NonNullConst<T>
impl<T> !Sync for NonNullConst<T>
impl<T> Unpin for NonNullConst<T>where
T: ?Sized,
impl<T> UnwindSafe for NonNullConst<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
Mutably borrows from an owned value. Read more