← Rule catalog

rust-doctor · Performance

collect-then-iterate

Flags `.collect::<Vec<_>>()` immediately followed by `.iter()`. This allocates a temporary vector unnecessarily since the original iterator could be used directly.

Severity
warning
Confidence
medium
Analyzer
syn-ast
Default policy
Enabled

Tags

  • heuristic
  • performance

Framework requirements

No framework requirement.

Limitations

  • Syntactic analysis does not have rustc name resolution or inferred type information.

Remediation

Remove the `.collect()` and chain the iterator operations directly.

Fix capability: guidance