This PR changes the result of calling chunked(on:) to [(Subject, SubSequence)], and adds a new collection type as the result of lazy.chunked(on:) with a matching element type. Including the projected Subject is often useful when chunking on a projected value like this.
The new versions of chunked(on:) looks like this:
extension Collection {
public func chunked<Subject: Equatable>(
on projection: (Element) throws -> Subject
) rethrows -> [(Subject, SubSequence)]
}
extension LazyCollectionProtocol {
public func chunked<Subject: Equatable>(
on projection: (Element) throws -> Subject
) rethrows -> ChunkedOn<Self, Subject>
}
I've also changed the name Chunked to be ChunkedBy, since this PR introduces ChunkedOn.
Checklist
[x] 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
This PR changes the result of calling
chunked(on:)
to[(Subject, SubSequence)]
, and adds a new collection type as the result oflazy.chunked(on:)
with a matching element type. Including the projectedSubject
is often useful when chunking on a projected value like this.The new versions of
chunked(on:)
looks like this:I've also changed the name
Chunked
to beChunkedBy
, since this PR introducesChunkedOn
.Checklist