2021-04-08 10:50:13 -05:00
|
|
|
error: needless use of `for_each`
|
2024-02-27 08:25:18 -06:00
|
|
|
--> tests/ui/needless_for_each_fixable.rs:15:5
|
2021-04-08 10:50:13 -05:00
|
|
|
|
|
|
|
|
LL | / v.iter().for_each(|elem| {
|
|
|
|
LL | | acc += elem;
|
|
|
|
LL | | });
|
|
|
|
| |_______^
|
|
|
|
|
|
|
|
|
= note: `-D clippy::needless-for-each` implied by `-D warnings`
|
2023-08-01 07:02:21 -05:00
|
|
|
= help: to override `-D warnings` add `#[allow(clippy::needless_for_each)]`
|
2021-04-08 10:50:13 -05:00
|
|
|
help: try
|
|
|
|
|
|
2021-08-11 09:21:33 -05:00
|
|
|
LL ~ for elem in v.iter() {
|
|
|
|
LL + acc += elem;
|
|
|
|
LL + }
|
2021-04-08 10:50:13 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
error: needless use of `for_each`
|
2024-02-27 08:25:18 -06:00
|
|
|
--> tests/ui/needless_for_each_fixable.rs:18:5
|
2021-04-08 10:50:13 -05:00
|
|
|
|
|
|
|
|
LL | / v.into_iter().for_each(|elem| {
|
|
|
|
LL | | acc += elem;
|
|
|
|
LL | | });
|
|
|
|
| |_______^
|
|
|
|
|
|
|
|
|
help: try
|
|
|
|
|
|
2021-08-11 09:21:33 -05:00
|
|
|
LL ~ for elem in v.into_iter() {
|
|
|
|
LL + acc += elem;
|
|
|
|
LL + }
|
2021-04-08 10:50:13 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
error: needless use of `for_each`
|
2024-02-27 08:25:18 -06:00
|
|
|
--> tests/ui/needless_for_each_fixable.rs:22:5
|
2021-04-08 10:50:13 -05:00
|
|
|
|
|
|
|
|
LL | / [1, 2, 3].iter().for_each(|elem| {
|
|
|
|
LL | | acc += elem;
|
|
|
|
LL | | });
|
|
|
|
| |_______^
|
|
|
|
|
|
|
|
|
help: try
|
|
|
|
|
|
2021-08-11 09:21:33 -05:00
|
|
|
LL ~ for elem in [1, 2, 3].iter() {
|
|
|
|
LL + acc += elem;
|
|
|
|
LL + }
|
2021-04-08 10:50:13 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
error: needless use of `for_each`
|
2024-02-27 08:25:18 -06:00
|
|
|
--> tests/ui/needless_for_each_fixable.rs:27:5
|
2021-04-08 10:50:13 -05:00
|
|
|
|
|
|
|
|
LL | / hash_map.iter().for_each(|(k, v)| {
|
|
|
|
LL | | acc += k + v;
|
|
|
|
LL | | });
|
|
|
|
| |_______^
|
|
|
|
|
|
|
|
|
help: try
|
|
|
|
|
|
2021-08-11 09:21:33 -05:00
|
|
|
LL ~ for (k, v) in hash_map.iter() {
|
|
|
|
LL + acc += k + v;
|
|
|
|
LL + }
|
2021-04-08 10:50:13 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
error: needless use of `for_each`
|
2024-02-27 08:25:18 -06:00
|
|
|
--> tests/ui/needless_for_each_fixable.rs:30:5
|
2021-04-08 10:50:13 -05:00
|
|
|
|
|
|
|
|
LL | / hash_map.iter_mut().for_each(|(k, v)| {
|
|
|
|
LL | | acc += *k + *v;
|
|
|
|
LL | | });
|
|
|
|
| |_______^
|
|
|
|
|
|
|
|
|
help: try
|
|
|
|
|
|
2021-08-11 09:21:33 -05:00
|
|
|
LL ~ for (k, v) in hash_map.iter_mut() {
|
|
|
|
LL + acc += *k + *v;
|
|
|
|
LL + }
|
2021-04-08 10:50:13 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
error: needless use of `for_each`
|
2024-02-27 08:25:18 -06:00
|
|
|
--> tests/ui/needless_for_each_fixable.rs:33:5
|
2021-04-08 10:50:13 -05:00
|
|
|
|
|
|
|
|
LL | / hash_map.keys().for_each(|k| {
|
|
|
|
LL | | acc += k;
|
|
|
|
LL | | });
|
|
|
|
| |_______^
|
|
|
|
|
|
|
|
|
help: try
|
|
|
|
|
|
2021-08-11 09:21:33 -05:00
|
|
|
LL ~ for k in hash_map.keys() {
|
|
|
|
LL + acc += k;
|
|
|
|
LL + }
|
2021-04-08 10:50:13 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
error: needless use of `for_each`
|
2024-02-27 08:25:18 -06:00
|
|
|
--> tests/ui/needless_for_each_fixable.rs:36:5
|
2021-04-08 10:50:13 -05:00
|
|
|
|
|
|
|
|
LL | / hash_map.values().for_each(|v| {
|
|
|
|
LL | | acc += v;
|
|
|
|
LL | | });
|
|
|
|
| |_______^
|
|
|
|
|
|
|
|
|
help: try
|
|
|
|
|
|
2021-08-11 09:21:33 -05:00
|
|
|
LL ~ for v in hash_map.values() {
|
|
|
|
LL + acc += v;
|
|
|
|
LL + }
|
2021-04-08 10:50:13 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
error: needless use of `for_each`
|
2024-02-27 08:25:18 -06:00
|
|
|
--> tests/ui/needless_for_each_fixable.rs:43:5
|
2021-04-08 10:50:13 -05:00
|
|
|
|
|
|
|
|
LL | / my_vec().iter().for_each(|elem| {
|
|
|
|
LL | | acc += elem;
|
|
|
|
LL | | });
|
|
|
|
| |_______^
|
|
|
|
|
|
|
|
|
help: try
|
|
|
|
|
|
2021-08-11 09:21:33 -05:00
|
|
|
LL ~ for elem in my_vec().iter() {
|
|
|
|
LL + acc += elem;
|
|
|
|
LL + }
|
2021-04-08 10:50:13 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
error: aborting due to 8 previous errors
|
|
|
|
|