Skip to content

Compiler optimization suggestion - Iter<String>.collect::<Vec<String>>().join("") #95165

Closed
@yoav-lavi

Description

@yoav-lavi

Hi,

I've opened this issue for clippy: rust-lang/rust-clippy#8570 wherein a collect::<Vec<String>>().join("") operation on an Iter<String> can be expressed as collect::<String>() which is more performant.

I wanted to put this here as well as I think this may be something that can also be optimized by the compiler (by replacing the former with the latter) since the output should always be equivalent and the latter option is more performant.

See cases of this happening in the wild here (GitHub CS Beta) or here (Sourcegraph)

I'm learning Rust so please let me know if I'm missing something, thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    S-inactiveStatus: Inactive and waiting on the author. This is often applied to closed PRs.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions