Skip to content

How do I compare a Span, e.g., using min() and max() methods? #337

Answered by BurntSushi
binChris asked this question in Q&A
Discussion options

You must be logged in to vote

You can't use min() and max() on them because they very intentionally don't implement Eq or Ord. Have you seen these parts of the docs?

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 like std::time::Duration and has all of the trait impls (like Eq and Ord) that you'd expect. You can read more about how to choose between a Span and a SignedDuration.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by binChris
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants