about summary refs log tree commit diff
path: root/src/libcore/ptr.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/libcore/ptr.rs')
-rw-r--r--src/libcore/ptr.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/libcore/ptr.rs b/src/libcore/ptr.rs
index c1e150e9fb9..f4e668328ce 100644
--- a/src/libcore/ptr.rs
+++ b/src/libcore/ptr.rs
@@ -2750,6 +2750,14 @@ impl<T: ?Sized> NonNull<T> {
             NonNull::new_unchecked(self.as_ptr() as *mut U)
         }
     }
+
+    /// Cast to a `Void` pointer
+    #[unstable(feature = "allocator_api", issue = "32838")]
+    pub fn as_void(self) -> NonNull<::alloc::Void> {
+        unsafe {
+            NonNull::new_unchecked(self.as_ptr() as _)
+        }
+    }
 }
 
 #[stable(feature = "nonnull", since = "1.25.0")]