summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/src/docs/manual_assert.txt
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools/clippy/src/docs/manual_assert.txt')
-rw-r--r--src/tools/clippy/src/docs/manual_assert.txt18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/tools/clippy/src/docs/manual_assert.txt b/src/tools/clippy/src/docs/manual_assert.txt
new file mode 100644
index 000000000..93653081a
--- /dev/null
+++ b/src/tools/clippy/src/docs/manual_assert.txt
@@ -0,0 +1,18 @@
+### What it does
+Detects `if`-then-`panic!` that can be replaced with `assert!`.
+
+### Why is this bad?
+`assert!` is simpler than `if`-then-`panic!`.
+
+### Example
+```
+let sad_people: Vec<&str> = vec![];
+if !sad_people.is_empty() {
+ panic!("there are sad people: {:?}", sad_people);
+}
+```
+Use instead:
+```
+let sad_people: Vec<&str> = vec![];
+assert!(sad_people.is_empty(), "there are sad people: {:?}", sad_people);
+``` \ No newline at end of file