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

Document details of Ord for Tuples, Option, Result, others? #50727

Closed
Havvy opened this issue May 14, 2018 · 7 comments
Closed

Document details of Ord for Tuples, Option, Result, others? #50727

Havvy opened this issue May 14, 2018 · 7 comments
Labels
A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools C-enhancement Category: An issue proposing an enhancement or a PR with one. E-medium Call for participation: Medium difficulty. Experience needed to fix: Intermediate. P-medium Medium priority T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@Havvy
Copy link
Contributor

Havvy commented May 14, 2018

In #rust, we had a user ask if Ord for (A, B, C) checks left to right or right to left. (It's left to right.)

This should be documented in the stdlib docs somewhere.

Similarly, should be documented for other enums such as Option (Some(T) > None) and Result (uhh, didn't check) and possibly others where it could be something different.

@durka
Copy link
Contributor

durka commented May 14, 2018

Definitely seems like it can't be left undocumented. Changing the sort order of Option in a future release would be a breaking change.

The sort order of derived ordering is mentioned in the docs: https://doc.rust-lang.org/std/cmp/trait.PartialOrd.html#derivable (same text is at Ord)

Would you want it somewhere else as well?

@estebank estebank added the A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools label May 14, 2018
@Havvy
Copy link
Contributor Author

Havvy commented May 14, 2018

@durka Even if the impl for these is via a #[derive], that information is disconnected from the actual impls when you look at the docs. And when we look at the impls, we don't see the declaration order of the struct members.

@QuietMisdreavus
Copy link
Member

QuietMisdreavus commented May 15, 2018

Documenting derived traits is a duplicate of #44118.

Tuples, on the other hand, don't get their traits via derive. All those traits are applied via a macro, so it's possible to add docs there without extending the language to add arbitrary attributes to a derive.

@steveklabnik steveklabnik added the E-medium Call for participation: Medium difficulty. Experience needed to fix: Intermediate. label May 28, 2018
@XAMPPRocky XAMPPRocky added the C-enhancement Category: An issue proposing an enhancement or a PR with one. label Oct 2, 2018
@steveklabnik steveklabnik added the P-medium Medium priority label Dec 27, 2018
@saleemjaffer
Copy link
Contributor

@steveklabnik @estebank I would like to take this up.

Centril added a commit to Centril/rust that referenced this issue Jun 7, 2019
…g, r=oli-obk

Document tuple's Ord behavior as sequential

Partially closing rust-lang#50727
Centril added a commit to Centril/rust that referenced this issue Jun 8, 2019
…g, r=oli-obk

Document tuple's Ord behavior as sequential

Partially closing rust-lang#50727
@jonas-schievink jonas-schievink added the T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. label Mar 6, 2020
@poliorcetics
Copy link
Contributor

Is there still something to do about this issue ? If yes, I would like to do it, but I see tuples have been documented and from what I understand the rest is apparently not needed.

@bertptrs
Copy link
Contributor

The ordering for Option and Result is documented through a small note in the Derivable section:

When derived on enums, variants are ordered by their discriminants. By default, the discriminant is smallest for variants at the top, and largest for variants at the bottom. Here’s an example:

And then it lists two examples. The ordering for both Result and Option is indeed simply derived so that covers that. However that fact could be considered an implementation detail, so I think it's still good to mention it explicitly on the relevant pages.

The sort order for tuples is defined in the tuple documentation and I think that should cover it.

@Dylan-DPC
Copy link
Member

Closing this as the documentation now mentions this albeit in different places

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 C-enhancement Category: An issue proposing an enhancement or a PR with one. E-medium Call for participation: Medium difficulty. Experience needed to fix: Intermediate. P-medium Medium priority T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests