mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-15 20:45:45 +03:00
28 lines
752 B
Plaintext
28 lines
752 B
Plaintext
error: this iterator reduction never loops (closure always diverges)
|
|
--> tests/ui/never_loop_iterator_reduction.rs:6:5
|
|
|
|
|
LL | / [0, 1].into_iter().for_each(|x| {
|
|
LL | |
|
|
LL | |
|
|
LL | | let _ = x;
|
|
LL | | panic!("boom");
|
|
LL | | });
|
|
| |______^
|
|
|
|
|
= note: if you only need one element, `if let Some(x) = iter.next()` is clearer
|
|
= note: `-D clippy::never-loop` implied by `-D warnings`
|
|
= help: to override `-D warnings` add `#[allow(clippy::never_loop)]`
|
|
help: consider this pattern
|
|
|
|
|
LL - [0, 1].into_iter().for_each(|x| {
|
|
LL -
|
|
LL -
|
|
LL - let _ = x;
|
|
LL - panic!("boom");
|
|
LL - });
|
|
LL + if let Some(x) = [0, 1].into_iter().next() { ... };
|
|
|
|
|
|
|
error: aborting due to 1 previous error
|
|
|