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

Make is_sorted[_by_key] require Ord instead of PartialOrd and remove Iterator::is_sorted_by_key #81382

Commits on Jan 30, 2021

  1. Remove Iterator::is_sorted_by_key

    This method can be trivially replaced by `iter.map(...).is_sorted()`.
    There has been some discussion about this, but the only reason for
    having that method that has been brought up is to have a more symmetry
    between the methods of `[T]` and `Iterator`. `[T]::is_sorted_by_key` is
    necessary, as there is not a simple replacement for it. But I don't
    think API symmetry is a strong enough argument for adding methods that
    are essentially superfluous or "a tiny bit convenient" at most.
    
    Finally, this method can always be added in the future. For the initial
    stabilization of the `is_sorted` API, it is not necessary.
    LukasKalbertodt committed Jan 30, 2021
    Configuration menu
    Copy the full SHA
    cb32cfb View commit details
    Browse the repository at this point in the history
  2. Change is_sorted[_by_key] methods to require Ord instead of `Part…

    …ialOrd`
    
    With `f32::total_cmp` and `f64::total_cmp`, the main reason for having
    an `PartialOrd` bound on these methods is mostly gone. By requiring
    `Ord`, we have no more edges cases with non-comparable values that need
    to be explained in the docs. These methods are now also in line with
    the `sort*` methods.
    
    Also note that `is_sorted` is mostly for convenience; if it is not
    powerful enough, there are more powerful tools that are only slightly
    less convenient. Finally, the trait bound can be relaxed in the future.
    LukasKalbertodt committed Jan 30, 2021
    Configuration menu
    Copy the full SHA
    3c047a2 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    324d5e9 View commit details
    Browse the repository at this point in the history