I've been playing around with parameter packs and trying to implement the body of ZipSequence.Iterator's next() method from SE-0398 with little success.
The code from the proposal for reference:
struct ZipSequence<each S: Sequence>: Sequence {
typealias Element = (repeat (each S).Element)
let seq: (repeat each S)
func makeIterator() -> Iterator {
return Iterator(iter: (repeat (each seq).makeIterator()))
}
struct Iterator: IteratorProtocol {
typealias Element = (repeat (each S).Element)
var iter: (repeat (each S).Iterator)
mutating func next() -> Element? {
return ???
}
}
}
func zip<each S>(
_ seq: repeat each S
) -> ZipSequence<repeat each S> where repeat each S: Sequence {
ZipSequence(seq: (repeat each seq))
}
I've tried using (repeat (each iter).next()) which results in the error `Cannot use mutating member on immutable value of type 'τ_1_0.Iterator'.
is there a way to implement this or does this require pack iteration to be implemented?