diff options
| -rw-r--r-- | src/libcore/heap.rs | 20 | ||||
| -rw-r--r-- | src/libcore/lib.rs | 1 |
2 files changed, 21 insertions, 0 deletions
diff --git a/src/libcore/heap.rs b/src/libcore/heap.rs index fe19c923a58..80eedb5bff2 100644 --- a/src/libcore/heap.rs +++ b/src/libcore/heap.rs @@ -21,6 +21,26 @@ use mem; use usize; use ptr::{self, NonNull}; +extern { + /// An opaque, unsized type. Used for pointers to allocated memory. + /// + /// This type can only be used behind a pointer like `*mut Void` or `ptr::NonNull<Void>`. + /// Such pointers are similar to C’s `void*` type. + pub type Void; +} + +impl Void { + /// Similar to `std::ptr::null`, which requires `T: Sized`. + pub fn null() -> *const Self { + 0 as _ + } + + /// Similar to `std::ptr::null_mut`, which requires `T: Sized`. + pub fn null_mut() -> *mut Self { + 0 as _ + } +} + /// Represents the combination of a starting address and /// a total capacity of the returned block. #[derive(Debug)] diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs index 9ff8465bc0f..722a9de215c 100644 --- a/src/libcore/lib.rs +++ b/src/libcore/lib.rs @@ -75,6 +75,7 @@ #![feature(custom_attribute)] #![feature(doc_cfg)] #![feature(doc_spotlight)] +#![feature(extern_types)] #![feature(fn_must_use)] #![feature(fundamental)] #![feature(intrinsics)] |
