-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Clarify Ord's requirement: what is needed for sort-order #8071
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
In #8357, @thestinger told me Container could use the default methods of Ord if T is a totally ordered set. |
I think we need https://gist.github.com/anonymous/17b1b418713e676d5cea I think we need to, for every Ord relation
which means, find the first nonequal element pair, and their comparison is the result. |
@blake2-ppc Great. I think |
#12517 can cover this as part of renaming and fixing the incorrect documentation and incorrect generic code. |
Thank you. |
…dnet Add new lint to warn when #[must_use] attribute should be used on a method This lint is somewhat similar to https://rust-lang.github.io/rust-clippy/master/index.html#must_use_candidate but also different: it emits a warning by default and only targets methods (so not functions nor associated functions). Someone suggested it to me after this tweet: https://twitter.com/m_ou_se/status/1466439813230477312 I think it would reduce the number of cases of API misuses quite a lot. What do you think? --- changelog: Added new [`return_self_not_must_use`] lint
AFAIK
Ord
is a trait "for values that can be compared for a sort-order" (quoted from doc) and is distinguished from total ordering (TotalOrd
). Sometimes it seems to be regarded as partial ordering. (cf. @cmr's comment at #7765.)However, some sort algorithms assume that
x ~ z
ifx ~ y
andy ~ z
. (a ~ b
here means!(a < b) && !(a > b)
. this relation is called equivalent or incomparable.) Without the assumption, in worst case O(N^2) comparison is needed to sort N elements. Strict partial ordering with this assumption is called strict weak ordering.I think it is necessary to clarify what we require to impls for
Ord
: partial ordering (probably minimum requirement), weak ordering, or something else.See also: #8360
The text was updated successfully, but these errors were encountered: