Skip to content

Commit e91689c

Browse files
committed
Rework documentation to be about fat pointers
1 parent 00716b4 commit e91689c

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/libcore/ptr.rs

+9-5
Original file line numberDiff line numberDiff line change
@@ -2483,9 +2483,13 @@ impl<T: ?Sized> Eq for *mut T {}
24832483
/// by their address rather than comparing the values they point to
24842484
/// (which is what the `PartialEq for &T` implementation does).
24852485
///
2486-
/// Smart pointer types, such as `Box`, `Rc`, and `Arc` do not compare
2487-
/// using this function, instead they compare the values rather than
2488-
/// their addresses.
2486+
/// A reference in Rust is sometimes stored different than a raw
2487+
/// memory address. These cases are called fat pointers. A reference
2488+
/// to a slice must store both the address of the slice and the length
2489+
/// of the slice. A reference to an object satisfying a trait must
2490+
/// also point to the vtable for the trait's methods. Since this
2491+
/// function compares pointers in totality, careful consideration to
2492+
/// the type of the variable must be made.
24892493
///
24902494
/// # Examples
24912495
///
@@ -2499,9 +2503,9 @@ impl<T: ?Sized> Eq for *mut T {}
24992503
/// let other_five_ref = &other_five;
25002504
///
25012505
/// assert!(five_ref == same_five_ref);
2502-
/// assert!(five_ref == other_five_ref);
2503-
///
25042506
/// assert!(ptr::eq(five_ref, same_five_ref));
2507+
///
2508+
/// assert!(five_ref == other_five_ref);
25052509
/// assert!(!ptr::eq(five_ref, other_five_ref));
25062510
/// ```
25072511
#[stable(feature = "ptr_eq", since = "1.17.0")]

0 commit comments

Comments
 (0)