This would be for situations where you are going to write the joined string out, or are appending to an existing String
. The alternatives right now are either extra allocations and copies via join
, or writing the annoying do-work-between-items loop yourself each time. Rust could get an ergonomics and performance win by having something like
impl [str] {
fn join_onto<W: Write>(&self, sep: &str, out: &mut W) { ... }
}
I’m not sure what this method should be called, or if it makes sense more as an extension to the slice or to the writer. Thoughts?