How do I compare a Span, e.g., using min() and max() methods?
#337
-
|
It is not obvious to me, how I would I compare Spans and use |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
You can't use If you don't need to represent calendar durations (units of days or above), then it's possible that you'll want a |
Beta Was this translation helpful? Give feedback.
You can't use
min()andmax()on them because they very intentionally don't implementEqorOrd. Have you seen these parts of the docs?SpanSpan::compareIf you don't need to represent calendar durations (units of days or above), then it's possible that you'll want a
SignedDurationinstead. That type is just likestd::time::Durationand has all of the trait impls (likeEqandOrd) that you'd expect. You can read more about how to choose between aSpanand aSignedDuration.