Mojo trait
Iterable
Describes a type that can produce an iterator by borrowing.
Conforming types implement __iter__(ref self), which borrows the
collection (immutably or mutably, depending on the call-site origin) and
returns an iterator whose elements may reference the source data. The
collection remains usable after iteration.
Implemented traits
comptime members
IteratorType
comptime IteratorType
The iterator type returned when borrowing this collection.
Parameterized on the mutability and origin so the iterator can yield references tied to the source collection's origin.
Required methods
__iter__
__iter__(ref self: _Self) -> _Self.IteratorType[self_is_mut, origin_of(self), origin_of(self)]
Borrows the collection and returns an iterator over its elements.
Returns:
_Self.IteratorType: An iterator over the elements.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!