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


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.)


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