Add labels to the tuples produced by `chunked(on:)`
Label the tuple produced by chunked(on:) (see #142) with subject and chunk. This aligns ChunkedOnCollection with the IndexedCollection, which specifies index and element as well as the built-in EnumeratedSequence (specifying offset and element).
This will also improve the legibility of code downstream of the said function. For example, when providing an identifier for SwiftUI's ForEach:
-ForEach(chunkedByDate, id: \.0) { date, items in
+ForEach(chunkedByDate, id: \.subject) { date, items in
The introduction of the label will have minimal impact on existing code, because the index-based address of the tuple component will remain unchanged and absent labels will be inferred. There may be extant usages of chunked(on:) where labels are specified and do rely on their absence in the current API, but these should be expected to be extremely rare and produce a compilation error that can be addressed easily. This said, the label choice should be considered carefully since subsequent relabelings will be certain to disrupt established code.
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
- [x] I've read the Contribution Guidelines
- [x] I've updated the documentation if necessary
Aside: Ruby’s analogue, chunk, has no meaningful naming to take guidance from.
The introduction of the label will have no effect on existing code
This is not strictly true because of Swift's tuple shuffle behavior, although it is unlikely to break correct working code.
@xwu, you are correct - amended the PR message to note this.