pub struct ShouldNotBeNull<T: ?Sized>(/* private fields */);Available on macOS only.
Expand description
A wrapper type around *mut T to communicate a pointer should not be null without introducing
undefined behaviour.
This is necessary for FFI, where, NonNull asks for much stronger
guarantees, which we can’t really provide when getting pointers from behind a C interface.
ShouldNotBeNull aims for the same usability as NonNull but with panics instead of undefined
behaviour when calling methods like as_ref().
Construction is done either directly from C since ShouldNotBeNull is a transparent wrapper or
with ShouldNotBeNull::new.
Implementations§
Trait Implementations§
Source§impl<T: ?Sized> Clone for ShouldNotBeNull<T>
impl<T: ?Sized> Clone for ShouldNotBeNull<T>
Source§impl<T: ?Sized> Debug for ShouldNotBeNull<T>
impl<T: ?Sized> Debug for ShouldNotBeNull<T>
Source§impl<T: ?Sized> PartialEq for ShouldNotBeNull<T>
impl<T: ?Sized> PartialEq for ShouldNotBeNull<T>
Source§impl<T: ?Sized> Pointer for ShouldNotBeNull<T>
impl<T: ?Sized> Pointer for ShouldNotBeNull<T>
impl<T: ?Sized> Copy for ShouldNotBeNull<T>
impl<T: ?Sized> Eq for ShouldNotBeNull<T>
Auto Trait Implementations§
impl<T> Freeze for ShouldNotBeNull<T>where
T: ?Sized,
impl<T> RefUnwindSafe for ShouldNotBeNull<T>where
T: RefUnwindSafe + ?Sized,
impl<T> !Send for ShouldNotBeNull<T>
impl<T> !Sync for ShouldNotBeNull<T>
impl<T> Unpin for ShouldNotBeNull<T>where
T: ?Sized,
impl<T> UnwindSafe for ShouldNotBeNull<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