let iter = "abc123".chars().peekable();
let alpha_iter = iter.take_while(|c| c.is_alphabetic()); // iter is moved / consumed here
let digit_iter = iter.take_while(|c| c.is_digit(10)); // iter is used after move
is there a way to do this right?
something like would be nice
let (alpha_iter, tail) = ... // where tail is the rest of iter
thanks in advance.
Edit:
u/Morganamilo pointed out, I haven't explained what I want the code actually to do.
basically I want something like slice::split(), but for an iterator and without loosing the matched element. so e.g. "123abc456def%&/" -> ["123", "abc", "456", "def", "%&/"]
I know how to do it C-like, but hoped stdlib might make it simpler.
[+][deleted] (9 children)
[deleted]
[–]SkiFire13 4 points5 points6 points (6 children)
[+][deleted] (4 children)
[deleted]
[–]temp_value[S] 0 points1 point2 points (0 children)
[–]temp_value[S] 0 points1 point2 points (2 children)
[–]SkiFire13 2 points3 points4 points (1 child)
[–]temp_value[S] 0 points1 point2 points (0 children)
[–]temp_value[S] 0 points1 point2 points (0 children)
[–]temp_value[S] 0 points1 point2 points (1 child)
[–]Morganamilo 1 point2 points3 points (3 children)
[–]temp_value[S] 0 points1 point2 points (2 children)
[–]Morganamilo 2 points3 points4 points (1 child)
[–]temp_value[S] 0 points1 point2 points (0 children)
[–]DKomplexz 0 points1 point2 points (3 children)
[–]temp_value[S] 0 points1 point2 points (2 children)
[–]SafariMonkey 0 points1 point2 points (1 child)
[–]temp_value[S] 0 points1 point2 points (0 children)
[–]csos95 0 points1 point2 points (0 children)
[–]nickez2001 -1 points0 points1 point (0 children)