From 98bf99e2f8cf8b357d63a67ce67d5fc5ceef8b3c Mon Sep 17 00:00:00 2001 From: Philipp Krones Date: Fri, 9 Sep 2022 13:36:26 +0200 Subject: Merge commit 'b52fb5234cd7c11ecfae51897a6f7fa52e8777fc' into clippyup --- src/docs/while_let_loop.txt | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 src/docs/while_let_loop.txt (limited to 'src/docs/while_let_loop.txt') 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 -- cgit 1.4.1-3-g733a5