Description
In other languages, this kind of functionality is easily achieved:
# my_fields can be an iterator
", ".join(my_fields)
In Rust, this currently only works on slices and vectors. However, in generic code, one usually has an iterator only, and I believe it should be simple to connect such an iterator if the item type is compatible.
Otherwise I fear people will start to throw in an intermediate collect::<Vec<String>>()
call, which has performance implications.
All details, code, and the current workaround using itertools.intersperse()
can be found in the respective question on stackoverflow.
Please note that this seems to be related to a more general issue, namely that some useful functionality is not implemented on Iterator, even though it could be: http://internals.rust-lang.org/t/add-dedup-for-iterator/1567 .
Meta
rustc 1.0.0-nightly (522d09d 2015-02-19) (built 2015-02-19)
binary: rustc
commit-hash: 522d09d
commit-date: 2015-02-19
build-date: 2015-02-19
host: x86_64-apple-darwin
release: 1.0.0-nightly