Hi, I have a problem that would be nicely solved if I could split up a slice and get an iterator over sub-slices, separated by elements that match a certain condition. I.e, exactly like the "split" method on slices, but I need the matching element to be contained in the sub-slices.
More accurately, I don't necessarily need the matching element (the delimiter) to be part of the sub-slices, but I somehow need to connect a particular sub-slice with the preceding delimiter in order to process that sub-slice. Given my original slice, what I ideally would like is something that repeatedly calls a function whose first argument is the delimiter, and the second argument is a slice (or an iterator) containing the following elements up until the next delimiter.
Any ideas how to achieve this nicely? I know I can solve this using nested for loops or similar, but I'm just having fun trying to solve toy problems in the most idiomatic/compact/readable way I can.