Namespace Subspace :: sus :: iter

Composable external iteration.

If you've found yourself with a collection of some kind, and needed to perform an operation on the elements of said collection, you'll quickly run into 'iterators'. Iterators are heavily used in idiomatic Rust code, so it's worth becoming familiar with them.

The use of iterators with collections is described in the collections documentation.

TODO: Write lots more here.

All iterators implement the Iterator concept. Part of implementing that requires inheriting from IteratorBase which provides a large number of methods for filtering or transforming the items produced by the iterator. All of these methods are "lazy" in that they construct a new iterator but do not touch the source which generates items until iteration begins.

Iterators can interact with standard ranges as well.

Classes

  • An iterator that holds a reference to another iterator and proxies calls through to it. Used to create multiple iterators that share underlying state. The ByRef class must outlive the iterator it refers to.

  • An iterator that yields the current count and the element during iteration.

  • An iterator that clones the elements of an underlying iterator.

  • An iterator that copies the elements of an underlying iterator.

  • An iterator that repeats endlessly.

  • An Iterator that never returns an Item.

  • An iterator that yields the current count and the element during iteration.

  • An iterator that filters based on a predicate function.

  • An iterator that uses a function to both filter and map elements from another Iterator.

  • An iterator that maps an iterator of types into an iterator of iterable types through a user-defined function, and then flattens them into an interator of those those iterable types' items.

  • An iterator that flattens an iterator of iterable types into an iterator of those iterable types' items.

  • An iterator that returns the inner iterator's values until it sees None, and then only returns None.

  • A generator type that is a sus::iter::Iterator over type T.

  • An iterator that calls a function with a reference to each element before yielding it.

  • An iterator's refcount on the owning collection, preventig mutation while the iterator is alive.

  • Reference counting outstanding iterators (and view types since they need to be able to produce iterators) in order to catch iterator invalidation and prevent them from being used afterward. Mutating the collection should check that the count is empty. This is much like a RefCell in Rust, using runtime verfication that modification does not occur while there are outstanding references.

  • The base class for all Iterator types.

  • The iterator created from a std::range via from_range.

  • Support for use of a sus::Iterator as a std::ranges::input_range in the std::ranges library.

  • An iterator that maps each item to a new type based on a map function.

  • An iterator that maps each item to a new type based on a map function.

  • An iterator that moves from the elements of an underlying iterator.

  • An Iterator that walks over at most a single Item.

  • An Iterator that walks over at most a single Item.

  • An iterator with a peek() that returns an optional reference to the next element.

  • An Iterator that walks over at most a single Item.

  • An Iterator that walks over at most a single Item.

  • An iterator that iterates over another iterator but in reverse.

  • An iterator to maintain state while iterating another iterator.

  • An iterator that skips over n elements of another iterator.

  • An iterator that rejects elements while pred returns true.

  • An iterator that skips over n elements of another iterator.

  • An Iterator that generates each item from a function that takes the previous item.

  • An iterator that only iterates over the first n iterations of another iterator.

  • An iterator that only accepts elements while pred returns true.

  • An iterator that iterates a group of other iterators simultaneously.

Functions

  • Constructs an Empty iterator, which is an empty iterator that returns nothing.

  • Produces an iterator over Item from a coroutine function that returns Generator<Item> and yields Items.

  • Constructs ToType from a type that can be turned into an Iterator over elements of type ItemType.

  • Constructs an Iterator from a std::ranges::input_range.

  • Constructs a Once iterator that will return o and then None.

  • Creates an iterator that lazily generates a value exactly once by invoking the provided closure.

  • Creates a new iterator that endlessly repeats a single element.

  • Creates a new iterator that repeats elements of type Item endlessly by applying the provided closure, the repeater, FnMut<Item()>.

  • Creates a new iterator where each successive item is computed based on the preceding one.

  • Constructs ToType from a type that can be turned into an Iterator over elements of type ItemType.

  • Converts the arguments to iterators and zips them.

Concepts

  • An Iterator able to yield elements from both ends.

  • An Iterator that knows its exact length.

  • Extend a collection with the contents of an iterator.

  • A concept that indicates ToType can be constructed from an Iterator, via sus::iter::from_iter<ToType>(Iterator<IterType>).

  • Conversion into an Iterator.

  • Conversion into an Iterator over any type of values.

  • A concept for all implementations of iterators. See IteratorBase for the methods on an Iterator.

  • A concept for testing if a type T is an Iterator without testing its Item type.

  • Trait to represent types that can be created by multiplying elements of an iterator.

  • Trait to represent types that can be created by adding elements of an iterator.

  • An iterator that reports an accurate length.

Type Aliases

Concept Aliases