What is the canonical method to convert an Iterator<&str> to a String, interspersed with some constant string (e.g. "\n")?
For instance, given:
let xs = vec!["first", "second", "third"];
let it = xs.iter();
There is a way to produce a string s by collecting into some Iterable and joining the result:
let s = it
.map(|&x| x)
.collect::<Vec<&str>>()
.join("\n");
However, this unnecessarily allocates memory for a Vec<&str>. Is there a more direct method?