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

derive more traits for core::ops::ControlFlow #96416

Closed
wants to merge 1 commit into from

Conversation

canndrew
Copy link
Contributor

I wanted to put a ControlFlow in a hash set but couldn't because it lacks the necessary impls. Is there any reason not to implement these?

Implement Hash, Eq, PartialOrd, Ord for ControlFlow.
@rust-highfive
Copy link
Collaborator

Hey! It looks like you've submitted a new PR for the library teams!

If this PR contains changes to any rust-lang/rust public library APIs then please comment with r? rust-lang/libs-api @rustbot label +T-libs-api -T-libs to request review from a libs-api team reviewer. If you're unsure where your change falls no worries, just leave it as is and the reviewer will take a look and make a decision to forward on if necessary.

Examples of T-libs-api changes:

  • Stabilizing library features
  • Introducing insta-stable changes such as new implementations of existing stable traits on existing stable types
  • Introducing new or changing existing unstable library APIs (excluding permanently unstable features / features without a tracking issue)
  • Changing public documentation in ways that create new stability guarantees
  • Changing observable runtime behavior of library APIs

@rustbot rustbot added the T-libs Relevant to the library team, which will review and decide on the PR/issue. label Apr 26, 2022
@rust-highfive
Copy link
Collaborator

r? @yaahc

(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 Apr 26, 2022
@canndrew
Copy link
Contributor Author

r? rust-lang/libs-api @rustbot label +T-libs-api -T-libs

@rustbot rustbot added T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. and removed T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Apr 26, 2022
@inquisitivecrystal inquisitivecrystal added C-enhancement Category: An issue proposing an enhancement or a PR with one. needs-fcp This change is insta-stable, so needs a completed FCP to proceed. A-control-flow Area: Control flow and removed A-control-flow Area: Control flow labels Apr 29, 2022
@@ -79,7 +79,7 @@ use crate::{convert, ops};
/// [`Break`]: ControlFlow::Break
/// [`Continue`]: ControlFlow::Continue
#[stable(feature = "control_flow_enum_type", since = "1.55.0")]
#[derive(Debug, Clone, Copy, PartialEq)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
Copy link
Member

@scottmcm scottmcm May 1, 2022

Choose a reason for hiding this comment

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

Ord/PartialOrd were intentionally left out as described in https://rust-lang.github.io/rfcs/3058-try-trait-v2.html#traits-for-controlflow

I'd be inclined to leave it like that, unless you can give a good reason why one variant is less than the other. (Personally I might make it PartialOrd + !Ord, where partial_cmp gives None for mixing the variants, because I think having the order of variants matter is a misfeature, but I understand that's an unpopular position so don't actually propose it here.)

Eq/Hash seem fine to add, though.

@Mark-Simulacrum Mark-Simulacrum added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 24, 2022
@Mark-Simulacrum
Copy link
Member

Going to move this back to waiting-on-author, since the PartialOrd/Ord probably should be dropped. It would be good to add a comment to this type with the explanation @scottmcm provided, so we don't accidentally do this in the future once that context has been paged out.

@yaahc
Copy link
Member

yaahc commented Jul 25, 2022

r? rust-lang/libs

I've been taking a break from the review rotation for a while and didn't realize this one was still assigned to me, sorry about that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: An issue proposing an enhancement or a PR with one. needs-fcp This change is insta-stable, so needs a completed FCP to proceed. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants