Mojo trait
ComparableCollectionElement
This trait denotes a trait composition of the CollectionElement
and Comparable
traits.
This is useful to have as a named entity since Mojo does not
currently support anonymous trait compositions to constrain
on CollectionElement & Comparable
in the parameter.
Implemented traitsβ
AnyType
,
CollectionElement
,
Comparable
,
Copyable
,
EqualityComparable
,
Movable
Methodsβ
__copyinit__
β
__copyinit__(inout self: T, existing: T, /)
Create a new instance of the value by copying an existing one.
Args:
- βexisting (
T
): The value to copy.
__moveinit__
β
__moveinit__(inout self: T, owned existing: T, /)
Create a new instance of the value by moving the value of another.
Args:
- βexisting (
T
): The value to move.
__lt__
β
__lt__(self: T, rhs: T) -> Bool
Define whether self
is less than rhs
.
Args:
- βrhs (
T
): The right hand side of the comparison.
Returns:
True if self
is less than rhs
.
__le__
β
__le__(self: T, rhs: T) -> Bool
Define whether self
is less than or equal to rhs
.
Args:
- βrhs (
T
): The right hand side of the comparison.
Returns:
True if self
is less than or equal to rhs
.
__eq__
β
__eq__(self: T, other: T) -> Bool
Define whether two instances of the object are equal to each other.
Args:
- βother (
T
): Another instance of the same type.
Returns:
True if the instances are equal according to the type's definition of equality, False otherwise.
__ne__
β
__ne__(self: T, other: T) -> Bool
Define whether two instances of the object are not equal to each other.
Args:
- βother (
T
): Another instance of the same type.
Returns:
True if the instances are not equal according to the type's definition of equality, False otherwise.
__gt__
β
__gt__(self: T, rhs: T) -> Bool
Define whether self
is greater than rhs
.
Args:
- βrhs (
T
): The right hand side of the comparison.
Returns:
True if self
is greater than rhs
.
__ge__
β
__ge__(self: T, rhs: T) -> Bool
Define whether self
is greater than or equal to rhs
.
Args:
- βrhs (
T
): The right hand side of the comparison.
Returns:
True if self
is greater than or equal to rhs
.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!
π What went wrong?