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 implementEq
orOrd
. Have you seen these parts of the docs?Span
Span::compare
If you don't need to represent calendar durations (units of days or above), then it's possible that you'll want a
SignedDuration
instead. That type is just likestd::time::Duration
and has all of the trait impls (likeEq
andOrd
) that you'd expect. You can read more about how to choose between aSpan
and aSignedDuration
.