Continuing the discussion from Add Sequence.split(maxLength:):
The linked gist is (another) try-out of a chunked sequence. There are separate versions for
Collection because the sequence version is capable of passing on single-pass and/or infinite sources and the collection version is fixed at using its source's
SubSequence for elements.
Instead of having chunks that are exactly adjacent, there's an option for padding between vended elements, which are source elements that are completely skipped and are not part of any vended return. The padding can be negative to instead allow overlap.
The collection version has a reduced capability over the sequence version, in that the former cannot use overlap but allow shorter-than-normal chunks. In that forbidden combination, there is no way to prevent a subsequence from being formed that would turn a trailing full-size chunk in the source collection from being included in the subsequence as a short-sized chunk. The only way would be to measure then cache where to stop. That test is cost-prohibitive for non-random-access collections, and wouldn't work when a subsequence would end inside the short-sized chunk part of the source collection.
Note that using a chunk size of 2 and an overlap of 1 (i.e. padding of -1) acts like the adjacent-pair sequence/collection idea.