struct GeneratorOfOne<T>

A generator that produces one or fewer instances of T.

Inheritance GeneratorType, SequenceType, _SequenceType, _Sequence_Type View Protocol Hierarchy →
Associated Types
Generator = GeneratorOfOne<T>

Type alias inferred.

Element = Generator.Element

Type alias inferred.

Import import Swift



Construct an instance that generates element!, or an empty sequence if element == nil.


init(_ element: T?)

Instance Methods

func generate()

GeneratorOfOne is also a SequenceType, so it generates a copy of itself


func generate() -> GeneratorOfOne<T>
mutating func next()

Advance to the next element and return it, or nil if no next element exists.

Requires: next() has not been applied to a copy of self since the copy was made, and no preceding call to has returned nil.


mutating func next() -> T?