Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generator.Element for SequenceType in Swift 3

Tags:

swift

swift3

For swift 2.2 I use this

extension SequenceType where Generator.Element == Character {

}

but when I want to convert into Swift 3 I have to use Sequence instead of SequenceType

But

extension Sequence where Generator.Element == Character {

}

yeilds

Use of undeclared type 'Generator'

So, how can resolve this issue?

like image 469
Vyacheslav Avatar asked Dec 19 '16 12:12

Vyacheslav


1 Answers

An overview of the language chances for Swift 3 can be found at https://swift.org/blog/swift-3-0-released/.

This particular change is part of SE-0006 Apply API Guidelines to the Standard Library:

The concept of "generator" is renamed to "iterator" across all APIs.

So your extension must be defined as

extension Sequence where Iterator.Element == Character {

}
like image 178
Martin R Avatar answered Oct 18 '22 18:10

Martin R