Mojo trait
IntervalElement
The trait denotes a trait composition of the Copyable, Movable, Writable, Intable, and Comparable traits. Which is also subtractable.
Implemented traits
AnyType,
Copyable,
EqualityComparable,
GreaterThanComparable,
GreaterThanOrEqualComparable,
Intable,
LessThanComparable,
LessThanOrEqualComparable,
Movable,
UnknownDestructibility,
Writable
Aliases
__copyinit__is_trivial
alias __copyinit__is_trivial
A flag (often compiler generated) to indicate whether the implementation of __copyinit__ is trivial.
The implementation of __copyinit__ is considered to be trivial if:
- The struct has a compiler-generated trivial
__copyinit__and all its fields have a trivial__copyinit__method.
In practice, it means the value can be copied by copying the bits from one location to another without side effects.
__del__is_trivial
alias __del__is_trivial
A flag (often compiler generated) to indicate whether the implementation of __del__ is trivial.
The implementation of __del__ is considered to be trivial if:
- The struct has a compiler-generated trivial destructor and all its fields
have a trivial
__del__method.
In practice, it means that the __del__ can be considered as no-op.
__moveinit__is_trivial
alias __moveinit__is_trivial
A flag (often compiler generated) to indicate whether the implementation of __moveinit__ is trivial.
The implementation of __moveinit__ is considered to be trivial if:
- The struct has a compiler-generated
__moveinit__and all its fields have a trivial__moveinit__method.
In practice, it means the value can be moved by moving the bits from one location to another without side effects.
Required methods
__copyinit__
__copyinit__(out self: _Self, existing: _Self, /)
Create a new instance of the value by copying an existing one.
Args:
- existing (
_Self): The value to copy.
Returns:
_Self
__moveinit__
__moveinit__(out self: _Self, var existing: _Self, /)
Create a new instance of the value by moving the value of another.
Args:
- existing (
_Self): The value to move.
Returns:
_Self
__lt__
__lt__(self: _Self, rhs: _Self) -> Bool
Define whether self is less than rhs.
Args:
- rhs (
_Self): The right hand side of the comparison.
Returns:
Bool: True if self is less than rhs.
__le__
__le__(self: _Self, rhs: _Self) -> Bool
Define whether self is less than or equal to rhs.
Args:
- rhs (
_Self): The right hand side of the comparison.
Returns:
Bool: True if self is less than or equal to rhs.
__eq__
__eq__(self: _Self, other: _Self) -> Bool
Define whether two instances of the object are equal to each other.
Args:
- other (
_Self): Another instance of the same type.
Returns:
Bool: True if the instances are equal according to the type's definition
of equality, False otherwise.
__gt__
__gt__(self: _Self, rhs: _Self) -> Bool
Define whether self is greater than rhs.
Args:
- rhs (
_Self): The right hand side of the comparison.
Returns:
Bool: True if self is greater than rhs.
__ge__
__ge__(self: _Self, rhs: _Self) -> Bool
Define whether self is greater than or equal to rhs.
Args:
- rhs (
_Self): The right hand side of the comparison.
Returns:
Bool: True if self is greater than or equal to rhs.
__sub__
__sub__(self: _Self, rhs: _Self) -> _Self
Subtracts rhs from self, must be implemented in concrete types.
Args:
- rhs (
_Self): The value to subtract from self.
Returns:
_Self: The result of subtracting rhs from self.
__int__
__int__(self: _Self) -> Int
Get the integral representation of the value.
Returns:
Int: The integral representation of the value.
write_to
write_to(self: _Self, mut writer: T)
Formats the string representation of this type to the provided Writer.
Args:
- writer (
T): The type conforming toWritable.
Provided methods
__ne__
__ne__(self: _Self, other: _Self) -> Bool
Define whether two instances of the object are not equal to each other.
Args:
- other (
_Self): Another instance of the same type.
Returns:
Bool: True if the instances are not equal according to the type's
definition of equality, False otherwise.
copy
copy(self: _Self) -> _Self
Explicitly construct a copy of self.
Returns:
_Self: A copy of this value.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!