RS.CLIPPY.WHILE_LET_LOOP
`loop { if let { ... } else break }`, which can be written as a `while let` loop
This checker is a Clippy lint created by The Rust Project Contributors. The documentation shown here is a copy of the original documentation for: while_let_loop. Copyright ©2025 The Rust Team. All rights reserved.
What it does
Detects loop + match combinations that are easier
written as a while let loop.
Why is this bad?
The while let loop is usually shorter and more
readable.
Example
let y = Some(1);
loop {
let x = match y {
Some(x) => x,
None => break,
};
// ..
}
Use instead:
let y = Some(1);
while let Some(x) = y {
// ..
};