rust-lang/rust-clippy
from_iter_instead_of_collect / needless_collect interaction questionable
已关闭
#6,533 创建于 2021年1月1日
C-enhancementI-false-negativeL-nurserygood first issue
仓库指标
- 星标
- (10,406 个星标)
- PR 合并指标
- (平均合并 19天 22小时) (30 天内合并 113 个 PR)
描述
for _i in Vec::from_iter([1, 2, 3].iter()) {}
clippy will suggest to use .collect() instead of from_iter() here but blindly replacing will not work because .collect() will need some kind of type hint.
Them again
for _i in [1, 2, 3].iter().collect::<Vec<&i32>>() {}
does not trigger clippy::needless_collect (although it should!; neither does the first example) because we can iterate over
for _i in [1, 2, 3].iter() {}
directly.