Skip to content

usability issue: connect()-like functionality is only available on slices, not on Iterator(Item=Str) #22754

Closed
@Byron

Description

@Byron

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-feature-requestCategory: A feature request, i.e: not implemented / a PR.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions