Trait `Comparable`
I looked around, but do not see an answer so far. Does Mojo have a Trait like
Comparable
to indicate that a Struct has implemented all of the comparison dunder methods? Something like:
10 Replies
EqualityComparable | Modular Docs
A type which can be compared for equality with other instances of itself.
erk.... ty!
search tool in docs site led me astray:
Because it went to "similar words" before "word found inside longer compound CamelCase term" I didn't look a ton deeper there. Derp.
oh, that's just for equality... just 2 of the 6 comparators:
==
and !=
I think tons of design work still needed to have such a trait
GitHub
[stdlib] add
Comparable
trait by helehex · Pull Request #2517 · m...adds a Comparable trait for comparison testing conformance.
explicitly conform FloatLiteral, IntLiteral, Int, and Set.
this PR was merged internally, so I'm pretty sure nightly will be updated with this
🎉
ty ❤️
I'm a fan composition so instead we can have
PartialOrd
trait which can make up Comparable
by composing EquallyComparable
We landed Comparable trait for now in today's nightly