2 files changed, 36 insertions, 1 deletions
diff --git a/Cargo.toml b/Cargo.toml
index 5165718..8da9914 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "ltptr"
-version = "0.1.4"
+version = "0.1.5"
edition = "2021"
license = "0BSD"
description = "Checked raw pointers."
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()
+ }
}
|