Skip to content
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

Merged
merged 3 commits into from
Jan 17, 2022
Merged

Copy an example to PartialOrd as well #92953

merged 3 commits into from
Jan 17, 2022

Conversation

azdavis
Copy link
Contributor

@azdavis azdavis commented Jan 16, 2022

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) of x: T.

@rust-highfive
Copy link
Collaborator

r? @dtolnay

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 16, 2022
Copy link
Member

@dtolnay dtolnay left a 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,
}

@azdavis
Copy link
Contributor Author

azdavis commented Jan 16, 2022

That's a great point. I think we could improve the part about "top-to-bottom discriminant order".

Copy link
Member

@dtolnay dtolnay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@dtolnay
Copy link
Member

dtolnay commented Jan 16, 2022

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Jan 16, 2022

📌 Commit bfe0a4e has been approved by dtolnay

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 16, 2022
bors added a commit to rust-lang-ci/rust that referenced this pull request Jan 17, 2022
…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
@bors bors merged commit 775fe37 into rust-lang:master Jan 17, 2022
@rustbot rustbot added this to the 1.60.0 milestone Jan 17, 2022
@azdavis azdavis deleted the azdavis-copy-example branch March 1, 2022 22:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants