Iterable
public protocol IterableA type that can hand out an iterator over its contents — what for-in
loops desugar through, and what most collections conform to.
Iterable is one level above Iterator: a collection conforms to
Iterable and produces a fresh Iter each call to iter(), leaving
the source intact. (Compare with Iterator, which is consumed in
place.) Every Iterator is also Iterable via the blanket
conformance below — iter() on an iterator returns itself.
Examples
for item in myCollection {
// identical to:
// var it = myCollection.iter();
// while let .Some(item) = it.next() { ... }
}Associated Types
type Item
type ItemThe element type that iteration yields.
type TargetIterator
type TargetIteratorThe concrete iterator type returned by iter(). Constrained so
TargetIterator.Item matches Self.Item.
Methods
func iter() -> TargetIterator
func iter() -> TargetIteratorBuilds a fresh iterator over the contents.
Defined in lang/std/iter/iterator.ks