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

core: add a reverse method to Ordering. #16155

Closed
wants to merge 1 commit into from

Conversation

huonw
Copy link
Member

@huonw huonw commented Aug 1, 2014

This flips the comparison and is designed to be used when sorting etc.

/// assert_eq!(data, [10u, 8, 5, 2]);
/// ```
#[inline]
pub fn reverse(self) -> Ordering {
Copy link
Member

Choose a reason for hiding this comment

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

The reversal iterator on iterators is called rev (as a data point). I don't think we have conventions around this or anything, however.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, I was considering flip too. (I want someone else to make the decision...)

Copy link
Member

Choose a reason for hiding this comment

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

invert is another option (yay bikeshedding).

Copy link
Member

Choose a reason for hiding this comment

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

Currently there are no instances of flip or invert in the standard library, reverse is used for mutably reversing a vector, and rev is used for reversing a forward iterator. (not much precedent to draw from). So long as it's #[experimental] it doesn't matter a whole lot.

@nham
Copy link
Contributor

nham commented Aug 1, 2014

Yay. I was just lamenting the lack of such a method earlier today.

@alexcrichton
Copy link
Member

Could you also mark this method as #[experimental]? This module has been previously stabilized and new items are generally considered experimental for at least awhile.

@huonw
Copy link
Member Author

huonw commented Aug 2, 2014

r?

This flips the comparison and is designed to be used when sorting etc.
bors added a commit that referenced this pull request Aug 3, 2014
This flips the comparison and is designed to be used when sorting etc.
@bors bors closed this Aug 3, 2014
@huonw huonw deleted the Ordering-reverse branch December 4, 2014 02:04
bors added a commit to rust-lang-ci/rust that referenced this pull request Jan 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants