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

Add an example for deriving PartialOrd on enums #88202

Merged
merged 1 commit into from
Sep 3, 2021
Merged

Add an example for deriving PartialOrd on enums #88202

merged 1 commit into from
Sep 3, 2021

Conversation

azdavis
Copy link
Contributor

@azdavis azdavis commented Aug 21, 2021

For some reason, I always forget which variants are smaller and which
are larger when you derive PartialOrd on an enum. And the wording in the
current docs is not entirely clear to me.

So, I often end up making a small enum, deriving PartialOrd on it, and
then writing a #[test] with an assert that the top one is smaller than
the bottom one (or the other way around) to figure out which way the
deriving goes.

So then I figured, it would be great if the standard library docs just
had that example, so if I keep forgetting, at least I can figure it out
quickly by looking at std's docs.

For some reason, I always forget which variants are smaller and which
are larger when you derive PartialOrd on an enum. And the wording in the
current docs is not entirely clear to me.

So, I often end up making a small enum, deriving PartialOrd on it, and
then writing a `#[test]` with an assert that the top one is smaller than
the bottom one (or the other way around) to figure out which way the
deriving goes.

So then I figured, it would be great if the standard library docs just
had that example, so if I keep forgetting, at least I can figure it out
quickly by looking at std's docs.
@rust-highfive
Copy link
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @joshtriplett (or someone else) soon.

Please see the contribution instructions for more information.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 21, 2021
@inquisitivecrystal inquisitivecrystal added A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Aug 24, 2021
@azdavis
Copy link
Contributor Author

azdavis commented Aug 30, 2021

@joshtriplett could this have a look? Thank you.

@jyn514
Copy link
Member

jyn514 commented Sep 2, 2021

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Sep 2, 2021

📌 Commit 003a636 has been approved by jyn514

@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 Sep 2, 2021
m-ou-se added a commit to m-ou-se/rust that referenced this pull request Sep 2, 2021
Add an example for deriving PartialOrd on enums

For some reason, I always forget which variants are smaller and which
are larger when you derive PartialOrd on an enum. And the wording in the
current docs is not entirely clear to me.

So, I often end up making a small enum, deriving PartialOrd on it, and
then writing a `#[test]` with an assert that the top one is smaller than
the bottom one (or the other way around) to figure out which way the
deriving goes.

So then I figured, it would be great if the standard library docs just
had that example, so if I keep forgetting, at least I can figure it out
quickly by looking at std's docs.
bors added a commit to rust-lang-ci/rust that referenced this pull request Sep 3, 2021
Rollup of 7 pull requests

Successful merges:

 - rust-lang#88202 (Add an example for deriving PartialOrd on enums)
 - rust-lang#88483 (Fix LLVM libunwind build for non-musl targets)
 - rust-lang#88507 (Add test case for using `slice::fill` with MaybeUninit)
 - rust-lang#88557 (small const generics cleanup)
 - rust-lang#88579 (remove redundant / misplaced sentence from docs)
 - rust-lang#88610 (Update outdated docs of array::IntoIter::new.)
 - rust-lang#88613 (Update primitive docs for rust 2021.)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit cb2be32 into rust-lang:master Sep 3, 2021
@rustbot rustbot added this to the 1.56.0 milestone Sep 3, 2021
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jan 17, 2022
…lnay

Copy an example to PartialOrd as well

In rust-lang#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`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants