-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Documents reference equality by address (#54197) #54755
Documents reference equality by address (#54197) #54755
Conversation
Clarification of the use of `ptr::eq` to test equality of references via address by pointer coercion
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @aidanhs (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
Thanks for your PR @lucasloisp! You should hear from @aidanhs or some one else soon. Ping from triage @aidanhs / @rust-lang/docs: This PR requires your review. |
/// let other_five_ref = &other_five; | ||
/// | ||
/// assert!(five_ref == same_five_ref); | ||
/// assert!(five_ref == other_five_ref); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Usually we want to demonstrate assert_eq!()
instead of assert!()
when you're asserting equality like this, but i feel like this gets the point across better if you can see the == being used, since we're talking about the use of ==
versus ptr::eq
in the first place. (Just leaving this comment for posterity.)
This looks great, thanks so much! Sorry for letting this one slip through the cracks. @bors r+ rollup |
📌 Commit 68236e0 has been approved by |
Oh, one thing before this gets put in. Can you edit the PR description to add the line "Fixes #54197" so GitHub will automatically close it when it's merged? |
…ss-eq, r=QuietMisdreavus Documents reference equality by address (rust-lang#54197) Clarification of the use of `ptr::eq` to test equality of references via address by pointer coercion, regarding issue rust-lang#54197 . The same example as in `ptr::eq` docs is shown here to clarify that `PartialEq` compares values pointed-to instead of via address (which can be desired in some cases)
…ss-eq, r=QuietMisdreavus Documents reference equality by address (rust-lang#54197) Clarification of the use of `ptr::eq` to test equality of references via address by pointer coercion, regarding issue rust-lang#54197 . The same example as in `ptr::eq` docs is shown here to clarify that `PartialEq` compares values pointed-to instead of via address (which can be desired in some cases)
…ss-eq, r=QuietMisdreavus Documents reference equality by address (rust-lang#54197) Clarification of the use of `ptr::eq` to test equality of references via address by pointer coercion, regarding issue rust-lang#54197 . The same example as in `ptr::eq` docs is shown here to clarify that `PartialEq` compares values pointed-to instead of via address (which can be desired in some cases)
…ss-eq, r=QuietMisdreavus Documents reference equality by address (rust-lang#54197) Clarification of the use of `ptr::eq` to test equality of references via address by pointer coercion, regarding issue rust-lang#54197 . The same example as in `ptr::eq` docs is shown here to clarify that `PartialEq` compares values pointed-to instead of via address (which can be desired in some cases)
Rollup of 16 pull requests Successful merges: - #54755 (Documents reference equality by address (#54197)) - #54811 (During rustc bootstrap, make default for `optimize` independent of `debug`) - #54825 (NLL says "borrowed content" instead of more precise "dereference of raw pointer") - #54860 (Add doc comments about safest way to initialize a vector of zeros) - #54869 (Fix mobile docs) - #54891 (Fix tracking issue for Once::is_completed) - #54913 (doc fix: it's auto traits that make for automatic implementations) - #54920 (Fix handling of #[must_use] on unit and uninhabited types) - #54932 (A handful of random string-related improvements) - #54936 (impl Eq+Hash for TyLayout) - #54950 (std: Synchronize global allocator on wasm32) - #54956 ("(using ..." doesn't have the matching ")") - #54958 (add a macro for static (compile-time) assertions) - #54967 (Remove incorrect span for second label inner macro invocation) - #54983 (Fix slice's benchmarks) - #54989 (Fix spelling in the documentation to htmldocck.py) Failed merges: r? @ghost
Clarification of the use of
ptr::eq
to test equality of references via address by pointer coercion, Fixes #54197 .The same example as in
ptr::eq
docs is shown here to clarify thatPartialEq
compares values pointed-to instead of via address (which can be desired in some cases)