[stdlib] Constraining AnySequence.init

... to only allow sequences where SubSequence.SubSequence ==
SubSequence. See swift-evolution proposal
https://github.com/apple/swift-evolution/blob/master/proposals/0014-constrained-AnySequence.md
for more details.
This commit is contained in:
Max Moiseev
2016-01-06 11:41:54 -08:00
parent ae41794715
commit 1600c52822
2 changed files with 71 additions and 60 deletions

View File

@@ -224,7 +224,14 @@ public struct AnySequence<Element> : SequenceType {
public typealias T = Element
/// Wrap and forward operations to `base`.
public init<S: SequenceType where S.Generator.Element == Element>(_ base: S) {
public init<
S: SequenceType
where
S.Generator.Element == Element,
S.SubSequence : SequenceType,
S.SubSequence.Generator.Element == Element,
S.SubSequence.SubSequence == S.SubSequence
>(_ base: S) {
_box = _SequenceBox(base)
}