diff options
| author | Mike Hommey <mh@glandium.org> | 2018-04-03 08:51:02 +0900 |
|---|---|---|
| committer | Simon Sapin <simon.sapin@exyr.org> | 2018-04-12 22:53:22 +0200 |
| commit | fddf51ee0b9765484fc316dbf3d4feb8ceea715d (patch) | |
| tree | 52814590ab7288801f78e8ee5493e156f3181017 /src/libcore/ptr.rs | |
| parent | fd242ee64c5488e64e2bb677d90f2460e017b7cb (diff) | |
| download | rust-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.rs | 8 |
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")] |
