IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /docs/manual/basics.md). For the complete Mojo documentation index, see llms.txt.
Skip to main content
Version: Nightly
For the complete Mojo documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /docs/manual/basics.md).

peekable

peekable(ref iterable: T) -> _PeekableIterator[T.IteratorType[iterable_is_mut, origin_of(iterable), origin_of(iterable)]]

Returns a peekable iterator that can use the peek method to look ahead at the next element without advancing the iterator.

Args:

  • iterable (T): The iterable to create a peekable iterator from.

Returns:

_PeekableIterator[T.IteratorType[iterable_is_mut, origin_of(iterable), origin_of(iterable)]]: A peekable iterator.

peekable(var iterable: T) -> _PeekableIterator[T.IteratorOwnedType]

Returns a peekable iterator that can use the peek method to look ahead at the next element without advancing the iterator, consuming the iterable.

Args:

  • iterable (T): The iterable to consume and create a peekable iterator from.

Returns:

_PeekableIterator[T.IteratorOwnedType]: A peekable iterator.