join-string
A simple crate to join the elements of iterators as a string, interspersing a separator between all elements.
This is done somewhat efficiently, if possible, meaning if the iterator is cheaply clonable you can
directly print the result of Join::join()
without creating a temporary String
in memory.
use Join;
assert_eq!;
println!;
// Output: oof rab zab
Note that the standard library already provides a similar Join
trait on slices, but not on interators, and the standard library version always directly returns a
new String
. And then there are multiple other similar crates that however work a bit differently,
e.g. having more restrictions on element and separator types or always returning a String
.