summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/src/docs/or_then_unwrap.txt
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools/clippy/src/docs/or_then_unwrap.txt')
-rw-r--r--src/tools/clippy/src/docs/or_then_unwrap.txt22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/tools/clippy/src/docs/or_then_unwrap.txt b/src/tools/clippy/src/docs/or_then_unwrap.txt
new file mode 100644
index 000000000..64ac53749
--- /dev/null
+++ b/src/tools/clippy/src/docs/or_then_unwrap.txt
@@ -0,0 +1,22 @@
+### What it does
+Checks for `.or(…).unwrap()` calls to Options and Results.
+
+### Why is this bad?
+You should use `.unwrap_or(…)` instead for clarity.
+
+### Example
+```
+// Result
+let value = result.or::<Error>(Ok(fallback)).unwrap();
+
+// Option
+let value = option.or(Some(fallback)).unwrap();
+```
+Use instead:
+```
+// Result
+let value = result.unwrap_or(fallback);
+
+// Option
+let value = option.unwrap_or(fallback);
+``` \ No newline at end of file