about summary refs log tree commit diff
path: root/src/libcore/ptr.rs
diff options
context:
space:
mode:
authorMike Hommey <mh@glandium.org>2018-04-03 08:51:02 +0900
committerSimon Sapin <simon.sapin@exyr.org>2018-04-12 22:53:22 +0200
commitfddf51ee0b9765484fc316dbf3d4feb8ceea715d (patch)
tree52814590ab7288801f78e8ee5493e156f3181017 /src/libcore/ptr.rs
parentfd242ee64c5488e64e2bb677d90f2460e017b7cb (diff)
downloadrust-fddf51ee0b9765484fc316dbf3d4feb8ceea715d.tar.gz
rust-fddf51ee0b9765484fc316dbf3d4feb8ceea715d.zip
Use NonNull<Void> instead of *mut u8 in the Alloc trait
Fixes #49608
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")]