GeneratorOf creates a generic Generator
(and Sequence
):
struct GeneratorOf : Generator, Sequence {
init(_ next: () -&g
This is a bug in the Swift stdlib header auto-generator. When resolving types, they replace equivalent types in some places they shouldn't. The actual definition here is supposed to be:
init<G : Generator where Generator.Element == T>(_ self_: G)
But since Generator.Element
is the same as T
, the tool replaces it. Apple's been working on fixing that.
(_ self_: G)
is standard syntax, though an admittedly unusual style that I haven't seen used elsewhere, except for in SequenceOf
, which was probably written by the same person. I suspect it's just how the developer named the variable, rather than having some deeper meaning.
Remember, the stdlib header isn't a "normal" header. Swift doesn't have headers. Apple does a special Apple-only trick to allow one.
Chris Lattner commented on this in the devforms.