我环顾四周,但到目前为止还没有看到答案。 Mojo 是否有一个 Trait 来Comparable表明 Struct 已经实现了所有的比较 dunder 方法?就像是:
trait Comparable:
# == equal
fn __eq__(self, other: Self) -> Bool: ...
# != not equal
fn __ne__(self, other: Self) -> Bool: ...
# > greater than
fn __gt__(self, other: Self) -> Bool: ...
# < less than
fn __lt__(self, other: Self) -> Bool: ...
# >= greater than or equal
fn __ge__(self, other: Self) -> Bool: ...
# <= less than or equal
fn __le__(self, other: Self) -> Bool: ...