Join vec/slice/iterator elements into an output stream directly


#1

Out of curiosity: Is there something equivalent to write!("{}", &mut output, vec.join(",")) that doesn’t require an intermediate allocation of a String? Something like vec.join_into(",", &mut output) which takes and output stream?

Is there a similar intermediate-allocation free version of s += vec.join(",")? (Of course, given the above, one could just use vec.join_into(",", &mut s) if it existed.)


#2

Itertools::format can do this, like write!(&mut w, "{}", vec.iter().format(","))