summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/src/docs/manual_unwrap_or.txt
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools/clippy/src/docs/manual_unwrap_or.txt')
-rw-r--r--src/tools/clippy/src/docs/manual_unwrap_or.txt20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/tools/clippy/src/docs/manual_unwrap_or.txt b/src/tools/clippy/src/docs/manual_unwrap_or.txt
new file mode 100644
index 000000000..1fd7d831b
--- /dev/null
+++ b/src/tools/clippy/src/docs/manual_unwrap_or.txt
@@ -0,0 +1,20 @@
+### What it does
+Finds patterns that reimplement `Option::unwrap_or` or `Result::unwrap_or`.
+
+### Why is this bad?
+Concise code helps focusing on behavior instead of boilerplate.
+
+### Example
+```
+let foo: Option<i32> = None;
+match foo {
+ Some(v) => v,
+ None => 1,
+};
+```
+
+Use instead:
+```
+let foo: Option<i32> = None;
+foo.unwrap_or(1);
+``` \ No newline at end of file