对于
swift 2.2,我使用它
extension SequenceType where Generator.Element == Character { }
但是当我想转换成Swift 3时我必须使用
序列而不是SequenceType
但
extension Sequence where Generator.Element == Character { }
yeilds
Use of undeclared type ‘Generator’
那么,如何解决这个问题呢?
可以在以下位置找到Swift 3语言概率的概述
https://swift.org/blog/swift-3-0-released/.
https://swift.org/blog/swift-3-0-released/.
这种特殊的变化
是SE-0006 Apply API Guidelines to the Standard Library的一部分:
The concept of “generator” is renamed to “iterator” across all APIs.
因此,您的扩展名必须定义为
extension Sequence where Iterator.Element == Character { }