needless-collect Disallow materializing an Iterator before a terminal operation Materializing an Iterator before a terminal operation allocates storage for values that are immediately discarded. Instead, you SHOULD apply the terminal operation to the Iterator directly. Materialization may intentionally isolate the terminal operation from later mutations, so the rewrite requires review. - Category: performance - Level: warning - Fix: suggestion - Scope: module Reported function length(values: Iterator): isize { return values.toArray().length; } Accepted function length(values: Iterator): isize { return values.count(); } Prior art - Clippy ยท needlesscollect language/linter/src/rules/performance/needlesscollect.rs:8