-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Copy an example to PartialOrd as well #92953
Conversation
r? @dtolnay (rust-highfive has picked a reviewer for you, use r? to override) |
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.
This says two contradictory things. The first sentence says it's based on discriminant order, and the second sentence says it's based on source order.
When those two are not the same thing, I feel like it's the job of exactly this documentation you're touching to make it clear what the behavior of the derived impl is.
#[derive(PartialEq, Eq, PartialOrd, Ord)]
enum N {
Two = 2,
One = 1,
}
That's a great point. I think we could improve the part about "top-to-bottom discriminant order". |
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.
Thanks!
@bors r+ rollup |
📌 Commit bfe0a4e has been approved by |
…askrgr Rollup of 10 pull requests Successful merges: - rust-lang#92795 (Link sidebar "location" heading to top of page) - rust-lang#92799 (Remove some unnecessary uses of `FieldDef::ident`) - rust-lang#92808 (Fix `try wrapping expression in variant` suggestion with struct field shorthand) - rust-lang#92819 (rustdoc: remove hand-rolled isatty) - rust-lang#92876 (Fix suggesting turbofish with lifetime arguments) - rust-lang#92921 (Rename Printer constructor from mk_printer() to Printer::new()) - rust-lang#92937 (rustdoc: Add missing dot separator) - rust-lang#92953 (Copy an example to PartialOrd as well) - rust-lang#92977 (Docs: recommend VecDeque instead of Vec::remove(0)) - rust-lang#92981 (fix const_ptr_offset_from tracking issue) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
In #88202 I added an example for deriving PartialOrd on enums, but only later did I realize that I actually put the example on Ord.
This copies the example to PartialOrd as well, which is where I intended for it to be.
We could also delete the example on Ord, but I see there's already some highly similar examples shared between Ord and PartialOrd, so I figured we could leave it.
I also changed some type annotations in an example from
x : T
to the more common style (in Rust) ofx: T
.