]> git.lizzy.rs Git - rust.git/commitdiff
Document that there are many possible null pointers
authorJosh Stone <jistone@redhat.com>
Fri, 29 Sep 2017 20:59:53 +0000 (13:59 -0700)
committerJosh Stone <jistone@redhat.com>
Fri, 29 Sep 2017 20:59:53 +0000 (13:59 -0700)
src/libcore/ptr.rs

index dddeda7f02dec2ee321815491c3acc7ca573d593..474658b65a154a0ab8854f17a8f9914a6f835b81 100644 (file)
@@ -476,6 +476,11 @@ pub unsafe fn write_volatile<T>(dst: *mut T, src: T) {
 impl<T: ?Sized> *const T {
     /// Returns `true` if the pointer is null.
     ///
+    /// Note that unsized types have many possible null pointers, as only the
+    /// raw data pointer is considered, not their length, vtable, etc.
+    /// Therefore, two pointers that are null may still not compare equal to
+    /// each other.
+    ///
     /// # Examples
     ///
     /// Basic usage:
@@ -1109,6 +1114,11 @@ pub fn align_offset(self, align: usize) -> usize {
 impl<T: ?Sized> *mut T {
     /// Returns `true` if the pointer is null.
     ///
+    /// Note that unsized types have many possible null pointers, as only the
+    /// raw data pointer is considered, not their length, vtable, etc.
+    /// Therefore, two pointers that are null may still not compare equal to
+    /// each other.
+    ///
     /// # Examples
     ///
     /// Basic usage: