Skip to content

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

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

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion library/core/src/ops/control_flow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.

pub enum ControlFlow<B, C = ()> {
/// Move on to the next phase of the operation as normal.
#[stable(feature = "control_flow_enum_type", since = "1.55.0")]
Expand Down