about summary refs log tree commit diff
path: root/src/docs/while_let_loop.txt
diff options
context:
space:
mode:
authorPhilipp Krones <hello@philkrones.com>2022-09-09 13:36:26 +0200
committerPhilipp Krones <hello@philkrones.com>2022-09-09 13:36:26 +0200
commit98bf99e2f8cf8b357d63a67ce67d5fc5ceef8b3c (patch)
tree9737ff22b257f29282e7538d9ecb264451a3c1c0 /src/docs/while_let_loop.txt
parent854f751b263dfac06dc3f635f8a9f92b8bc51da6 (diff)
downloadrust-98bf99e2f8cf8b357d63a67ce67d5fc5ceef8b3c.tar.gz
rust-98bf99e2f8cf8b357d63a67ce67d5fc5ceef8b3c.zip
Merge commit 'b52fb5234cd7c11ecfae51897a6f7fa52e8777fc' into clippyup
Diffstat (limited to 'src/docs/while_let_loop.txt')
-rw-r--r--src/docs/while_let_loop.txt25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/docs/while_let_loop.txt b/src/docs/while_let_loop.txt
new file mode 100644
index 00000000000..ab7bf60975e
--- /dev/null
+++ b/src/docs/while_let_loop.txt
@@ -0,0 +1,25 @@
+### 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.
+
+### Known problems
+Sometimes the wrong binding is displayed ([#383](https://github.com/rust-lang/rust-clippy/issues/383)).
+
+### Example
+```
+loop {
+    let x = match y {
+        Some(x) => x,
+        None => break,
+    };
+    // .. do something with x
+}
+// is easier written as
+while let Some(x) = y {
+    // .. do something with x
+};
+```
\ No newline at end of file