Note that the overload on LazyCollectionProtocol returns a LazyCollection<SplitCollection<Elements, Separator>> rather than a SplitCollection<Self, Separator>. The purpose of this is to have it return slices of the underlying collection, rather than slices of the lazy wrapper.
We'll also need to unify the name of the type added here (currently SplitCollection) with the type returned by the lazy split operation that takes a single element separator (currently LazySplitCollection).
extension Collection {
public func split<Separator: Collection>(
separator: Separator,
maxSplits: Int = Int.max,
omittingEmptySubsequences: Bool = true,
by areEquivalent: (Element, Separator.Element) throws -> Bool
) rethrows -> [SubSequence]
}
extension Collection where Element: Equatable {
public func split<Separator: Collection>(
separator: Separator,
maxSplits: Int = Int.max,
omittingEmptySubsequences: Bool = true
) -> SplitCollection<Self, Separator>
where Separator.Element == Element
}
extension LazyCollectionProtocol {
public func split<Separator: Collection>(
separator: Separator,
maxSplits: Int = Int.max,
omittingEmptySubsequences: Bool = true,
by areEquivalent: @escaping (Element, Separator.Element) -> Bool
) -> LazyCollection<SplitCollection<Elements, Separator>>
}
extension LazyCollectionProtocol where Element: Equatable {
public func split<Separator: Collection>(
separator: Separator,
maxSplits: Int = Int.max,
omittingEmptySubsequences: Bool = true
) -> LazyCollection<SplitCollection<Elements, Separator>>
where Separator.Element == Element
}
Checklist
[ ] I've added at least one test that validates that my change is working, if appropriate
[x] I've followed the code style of the rest of the project
Depends on #154.
Note that the overload on
LazyCollectionProtocol
returns aLazyCollection<SplitCollection<Elements, Separator>>
rather than aSplitCollection<Self, Separator>
. The purpose of this is to have it return slices of the underlying collection, rather than slices of the lazy wrapper.We'll also need to unify the name of the type added here (currently
SplitCollection
) with the type returned by the lazysplit
operation that takes a single element separator (currentlyLazySplitCollection
).Checklist