Skip to content

Conversation

natecook1000
Copy link
Member

@natecook1000 natecook1000 commented May 11, 2021

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

  • I've added at least one test that validates that my change is working, if appropriate
  • I've followed the code style of the rest of the project
  • I've read the Contribution Guidelines
  • I've updated the documentation if necessary

@natecook1000 natecook1000 requested a review from timvermeulen May 11, 2021 22:04
@timvermeulen timvermeulen added the source breaking This change affects existing source code label May 12, 2021
@natecook1000
Copy link
Member Author

@swift-ci Please test

@natecook1000 natecook1000 merged commit 3484ac3 into main May 16, 2021
@natecook1000 natecook1000 deleted the nate/chunkedby_subject branch May 16, 2021 20:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
source breaking This change affects existing source code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants