diff options
author | SoniEx2 <endermoneymod@gmail.com> | 2024-12-07 07:54:29 -0300 |
---|---|---|
committer | SoniEx2 <endermoneymod@gmail.com> | 2024-12-07 07:54:39 -0300 |
commit | 6ecb7cd29ffe756cc80c81510fcb0e902dc99f9c (patch) | |
tree | 82f892ae89610ceb97badb268ef5b36c59ccc00e /src/lib.rs | |
parent | 0cbd0b9b701c4d067b8dd0fdccc0ebe5c6b6e7e1 (diff) |
Diffstat (limited to 'src/lib.rs')
-rw-r--r-- | src/lib.rs | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/lib.rs b/src/lib.rs index 7ce25cb..ad2905d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -165,6 +165,24 @@ impl<'a, T: ?Sized> ConstLtPtr<'a, T> { pub const unsafe fn as_raw(&self) -> *const T { self.raw } + + /// Checks if this pointer is null. + /// + /// # Examples + /// + /// A null pointer is null: + /// + /// ```rust + /// use ltptr::ConstLtPtr; + /// + /// let raw_ptr = core::ptr::null::<()>(); + /// let lt_ptr = unsafe { ConstLtPtr::from_raw(raw_ptr) }; + /// assert!(lt_ptr.is_null()); + /// ``` + #[inline] + pub fn is_null(self) -> bool { + self.raw.is_null() + } } impl<'a, T: ?Sized> MutLtPtr<'a, T> { @@ -193,4 +211,21 @@ impl<'a, T: ?Sized> MutLtPtr<'a, T> { pub const unsafe fn as_raw(&self) -> *mut T { self.raw } + + /// Checks if this pointer is null. + /// # Examples + /// + /// A null pointer is null: + /// + /// ```rust + /// use ltptr::MutLtPtr; + /// + /// let raw_ptr = core::ptr::null_mut::<()>(); + /// let lt_ptr = unsafe { MutLtPtr::from_raw(raw_ptr) }; + /// assert!(lt_ptr.is_null()); + /// ``` + #[inline] + pub fn is_null(self) -> bool { + self.raw.is_null() + } } |