I have a use case where I want to take elements from an iterator until a certain condition.
take_while function seemed to be made for that, however it removes an element!
While looking for a better solution, I noticed that with a slice, the
split function would have the same "problem". (It's only a problem in my use case)
In this simple example, i want to split the iterator or slice into
let v = [1,2,3,4,5]; //take_while let mut it = v.iter(); it.by_ref().take_while(|&&a|a<3); // 1, 2 it; // 4, 5 //split v.split(|&a|a==3); //[1,2], [4,5]
3 is removed.
How should I do this instead? Is there some function I'm missing?
I know I can just use a while loop and some mutable state, but I would like a clean solution.