Skip to content

Commit ae3ab9a

Browse files
committed
Implement some protocol conformance suggestions.
These are the suggestions I currently understand. Need to ponder the others and maybe ask questions.
1 parent 1657e26 commit ae3ab9a

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

Sources/Algorithms/LazySplitCollection.swift

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
/// x.split(maxSplits:omittingEmptySubsequences:whereSeparator)
1818
/// x.split(separator:maxSplits:omittingEmptySubsequences)
1919
///
20-
/// where `x` conforms to `LazyCollection`.
20+
/// where `x` conforms to `LazyCollectionProtocol`.
2121
public struct LazySplitCollection<Base: LazyCollectionProtocol>
22-
where Base.Element: Equatable, Base.Elements.Index == Base.Index {
22+
where Base.Elements.Index == Base.Index {
2323
internal let base: Base
2424
internal let isSeparator: (Base.Element) -> Bool
2525
internal let maxSplits: Int
@@ -53,7 +53,7 @@ extension LazySplitCollection {
5353
}
5454
}
5555

56-
extension LazySplitCollection.Iterator: IteratorProtocol, Sequence {
56+
extension LazySplitCollection.Iterator: IteratorProtocol {
5757
public typealias Element = Base.Elements.SubSequence
5858

5959
public mutating func next() -> Element? {
@@ -148,7 +148,7 @@ extension LazySplitCollection: LazySequenceProtocol {
148148
}
149149
}
150150

151-
extension LazyCollection where Element: Equatable {
151+
extension LazyCollectionProtocol where Elements.Index == Index {
152152
/// Lazily returns the longest possible subsequences of the collection, in order,
153153
/// that don't contain elements satisfying the given predicate.
154154
///
@@ -227,7 +227,7 @@ extension LazyCollection where Element: Equatable {
227227
func split(
228228
maxSplits: Int = Int.max,
229229
omittingEmptySubsequences: Bool = true,
230-
whereSeparator isSeparator: @escaping (Base.Element) -> Bool
230+
whereSeparator isSeparator: @escaping (Element) -> Bool
231231
) -> LazySplitCollection<Self> {
232232
precondition(maxSplits >= 0, "Must take zero or more splits")
233233

@@ -238,7 +238,9 @@ extension LazyCollection where Element: Equatable {
238238
omittingEmptySubsequences: omittingEmptySubsequences
239239
)
240240
}
241+
}
241242

243+
extension LazyCollectionProtocol where Element: Equatable, Elements.Index == Index {
242244
/// Lazily returns the longest possible subsequences of the collection, in order,
243245
/// around elements equal to the given element.
244246
///

0 commit comments

Comments
 (0)