@@ -51,7 +51,7 @@ pub use intrinsics::write_bytes;
51
51
/// ```
52
52
#[ inline]
53
53
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
54
- pub fn null < T > ( ) -> * const T { 0 as * const T }
54
+ pub const fn null < T > ( ) -> * const T { 0 as * const T }
55
55
56
56
/// Creates a null mutable raw pointer.
57
57
///
@@ -65,7 +65,7 @@ pub fn null<T>() -> *const T { 0 as *const T }
65
65
/// ```
66
66
#[ inline]
67
67
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
68
- pub fn null_mut < T > ( ) -> * mut T { 0 as * mut T }
68
+ pub const fn null_mut < T > ( ) -> * mut T { 0 as * mut T }
69
69
70
70
/// Swaps the values at two mutable locations of the same type, without
71
71
/// deinitialising either. They may overlap, unlike `mem::swap` which is
@@ -163,7 +163,7 @@ impl<T: ?Sized> *const T {
163
163
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
164
164
#[ inline]
165
165
pub fn is_null ( self ) -> bool where T : Sized {
166
- self == 0 as * const T
166
+ self == null ( )
167
167
}
168
168
169
169
/// Returns `None` if the pointer is null, or else returns a reference to
@@ -212,7 +212,7 @@ impl<T: ?Sized> *mut T {
212
212
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
213
213
#[ inline]
214
214
pub fn is_null ( self ) -> bool where T : Sized {
215
- self == 0 as * mut T
215
+ self == null_mut ( )
216
216
}
217
217
218
218
/// Returns `None` if the pointer is null, or else returns a reference to
0 commit comments