Mojo trait
Indexer
The Indexer
trait is used for types that can index into a collection or pointer. The type returned is the underlying __mlir_type.index, enabling types like UInt
to not have to be converted to an Int
first. This type is implicitly convertible to an Int
, so can be used anywhere an Int
can e.g. for comparisons.
Implemented traits
AnyType
,
Intable
,
UnknownDestructibility
Methods
__index__
__index__(self: _Self) -> index
Convert to index.
Returns:
The corresponding __mlir_type.index value.
__int__
__int__(self: _Self) -> Int
Get the integral representation of the value.
Returns:
The integral representation of the value.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!