How can i convert an iterator to tuple?

Hi,

If i have a string that looks like this abcd:ef how can extract to two variables in rust

example (not working)

let (a1, a2) = item.split(':').collect::<(&str, &str)>();

There's collect tuple in itertools: https://docs.rs/itertools/0.8.0/itertools/trait.Itertools.html#method.collect_tuple

In std, I think you'll have to call .next repeatedly.

1 Like