File tree 1 file changed +25
-0
lines changed 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -908,11 +908,36 @@ mod prim_usize { }
908
908
/// `&mut T` references can be freely coerced into `&T` references with the same referent type, and
909
909
/// references with longer lifetimes can be freely coerced into references with shorter ones.
910
910
///
911
+ /// Reference equality by address, instead of comparing the values pointed to, is accomplished via
912
+ /// implicit reference-pointer coercion and raw pointer equality via [`ptr::eq`], while
913
+ /// [`PartialEq`] compares values.
914
+ ///
915
+ /// [`ptr::eq`]: ptr/fn.eq.html
916
+ /// [`PartialEq`]: cmp/trait.PartialEq.html
917
+ ///
918
+ /// ```
919
+ /// use std::ptr;
920
+ ///
921
+ /// let five = 5;
922
+ /// let other_five = 5;
923
+ /// let five_ref = &five;
924
+ /// let same_five_ref = &five;
925
+ /// let other_five_ref = &other_five;
926
+ ///
927
+ /// assert!(five_ref == same_five_ref);
928
+ /// assert!(five_ref == other_five_ref);
929
+ ///
930
+ /// assert!(ptr::eq(five_ref, same_five_ref));
931
+ /// assert!(!ptr::eq(five_ref, other_five_ref));
932
+ /// ```
933
+ ///
911
934
/// For more information on how to use references, see [the book's section on "References and
912
935
/// Borrowing"][book-refs].
913
936
///
914
937
/// [book-refs]: ../book/second-edition/ch04-02-references-and-borrowing.html
915
938
///
939
+ /// # Trait implementations
940
+ ///
916
941
/// The following traits are implemented for all `&T`, regardless of the type of its referent:
917
942
///
918
943
/// * [`Copy`]
You can’t perform that action at this time.
0 commit comments