diff options
| author | Paul Lietar <paul@lietar.net> | 2017-09-03 19:53:58 +0100 |
|---|---|---|
| committer | Paul LiƩtar <lietar@google.com> | 2017-10-27 23:01:34 +0200 |
| commit | 77f7e85d7f4ebcc1a291edae95a3747b0e54d7fa (patch) | |
| tree | 3a10519372a957925738544a8a7cb651139e7fb5 /src/libcore | |
| parent | bed9a85c40f98ab8f4445b66d285d4108de9ad21 (diff) | |
| download | rust-77f7e85d7f4ebcc1a291edae95a3747b0e54d7fa.tar.gz rust-77f7e85d7f4ebcc1a291edae95a3747b0e54d7fa.zip | |
Implement RFC 1861: Extern types
Diffstat (limited to 'src/libcore')
| -rw-r--r-- | src/libcore/ptr.rs | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/libcore/ptr.rs b/src/libcore/ptr.rs index 01990f61fee..4a52ec5ee78 100644 --- a/src/libcore/ptr.rs +++ b/src/libcore/ptr.rs @@ -485,8 +485,9 @@ impl<T: ?Sized> *const T { /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[inline] - pub fn is_null(self) -> bool where T: Sized { - self == null() + pub fn is_null(self) -> bool { + // cast to () pointer, as T may not be sized + self as *const () == null() } /// Returns `None` if the pointer is null, or else returns a reference to @@ -517,7 +518,7 @@ impl<T: ?Sized> *const T { /// ``` #[stable(feature = "ptr_as_ref", since = "1.9.0")] #[inline] - pub unsafe fn as_ref<'a>(self) -> Option<&'a T> where T: Sized { + pub unsafe fn as_ref<'a>(self) -> Option<&'a T> { if self.is_null() { None } else { @@ -1116,8 +1117,9 @@ impl<T: ?Sized> *mut T { /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[inline] - pub fn is_null(self) -> bool where T: Sized { - self == null_mut() + pub fn is_null(self) -> bool { + // cast to () pointer, as T may not be sized + self as *mut () == null_mut() } /// Returns `None` if the pointer is null, or else returns a reference to @@ -1148,7 +1150,7 @@ impl<T: ?Sized> *mut T { /// ``` #[stable(feature = "ptr_as_ref", since = "1.9.0")] #[inline] - pub unsafe fn as_ref<'a>(self) -> Option<&'a T> where T: Sized { + pub unsafe fn as_ref<'a>(self) -> Option<&'a T> { if self.is_null() { None } else { @@ -1272,7 +1274,7 @@ impl<T: ?Sized> *mut T { /// ``` #[stable(feature = "ptr_as_ref", since = "1.9.0")] #[inline] - pub unsafe fn as_mut<'a>(self) -> Option<&'a mut T> where T: Sized { + pub unsafe fn as_mut<'a>(self) -> Option<&'a mut T> { if self.is_null() { None } else { |
