about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorVadim Petrochenkov <vadim.petrochenkov@gmail.com>2015-09-02 22:06:04 +0300
committerVadim Petrochenkov <vadim.petrochenkov@gmail.com>2015-09-03 09:03:52 +0300
commit3903ea96f557dc923cf73d3905554083cd921a01 (patch)
tree68fc6c84fc3767ea2d797cc400b801cee9a23241 /src
parent69c3b39d0d7136aff5ddb6e4cb08db3dca0621fc (diff)
downloadrust-3903ea96f557dc923cf73d3905554083cd921a01.tar.gz
rust-3903ea96f557dc923cf73d3905554083cd921a01.zip
Make `null()` and `null_mut()` const functions
Diffstat (limited to 'src')
-rw-r--r--src/libcore/ptr.rs8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/libcore/ptr.rs b/src/libcore/ptr.rs
index b7479b0c604..09dbffe6156 100644
--- a/src/libcore/ptr.rs
+++ b/src/libcore/ptr.rs
@@ -51,7 +51,7 @@ pub use intrinsics::write_bytes;
 /// ```
 #[inline]
 #[stable(feature = "rust1", since = "1.0.0")]
-pub fn null<T>() -> *const T { 0 as *const T }
+pub const fn null<T>() -> *const T { 0 as *const T }
 
 /// Creates a null mutable raw pointer.
 ///
@@ -65,7 +65,7 @@ pub fn null<T>() -> *const T { 0 as *const T }
 /// ```
 #[inline]
 #[stable(feature = "rust1", since = "1.0.0")]
-pub fn null_mut<T>() -> *mut T { 0 as *mut T }
+pub const fn null_mut<T>() -> *mut T { 0 as *mut T }
 
 /// Swaps the values at two mutable locations of the same type, without
 /// deinitialising either. They may overlap, unlike `mem::swap` which is
@@ -163,7 +163,7 @@ impl<T: ?Sized> *const T {
     #[stable(feature = "rust1", since = "1.0.0")]
     #[inline]
     pub fn is_null(self) -> bool where T: Sized {
-        self == 0 as *const T
+        self == null()
     }
 
     /// Returns `None` if the pointer is null, or else returns a reference to
@@ -212,7 +212,7 @@ impl<T: ?Sized> *mut T {
     #[stable(feature = "rust1", since = "1.0.0")]
     #[inline]
     pub fn is_null(self) -> bool where T: Sized {
-        self == 0 as *mut T
+        self == null_mut()
     }
 
     /// Returns `None` if the pointer is null, or else returns a reference to