Commit 0b70cac
committed
Add labels to the tuples produced by
Label the tuple produced by `chunked(on:)` with `subject` and
`chunk`. This will 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
```
This aligns `ChunkedOnCollection` with the `IndexedCollection`,
which specifies `index` and `element` as well as the built-in
`EnumeratedSequence` (specifying `offset` and `element`).
The introduction of the label will have no effect on existing code,
because the index-based address of the tuple component will remain
unchanged and absent labels will be inferred.chunked(on:)
1 parent 0e939e7 commit 0b70cac
File tree
2 files changed
+13
-2
lines changed- Sources/Algorithms
- Tests/SwiftAlgorithmsTests
2 files changed
+13
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
162 | 162 | | |
163 | 163 | | |
164 | 164 | | |
| 165 | + | |
165 | 166 | | |
166 | 167 | | |
167 | 168 | | |
| |||
174 | 175 | | |
175 | 176 | | |
176 | 177 | | |
177 | | - | |
| 178 | + | |
178 | 179 | | |
179 | 180 | | |
180 | 181 | | |
| |||
509 | 510 | | |
510 | 511 | | |
511 | 512 | | |
512 | | - | |
| 513 | + | |
513 | 514 | | |
514 | 515 | | |
515 | 516 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
74 | 84 | | |
75 | 85 | | |
76 | 86 | | |
| |||
0 commit comments