diff options
Diffstat (limited to '')
-rw-r--r-- | src/tools/clippy/src/docs/chars_last_cmp.txt | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/tools/clippy/src/docs/chars_last_cmp.txt b/src/tools/clippy/src/docs/chars_last_cmp.txt new file mode 100644 index 000000000..4c1d88389 --- /dev/null +++ b/src/tools/clippy/src/docs/chars_last_cmp.txt @@ -0,0 +1,17 @@ +### What it does +Checks for usage of `_.chars().last()` or +`_.chars().next_back()` on a `str` to check if it ends with a given char. + +### Why is this bad? +Readability, this can be written more concisely as +`_.ends_with(_)`. + +### Example +``` +name.chars().last() == Some('_') || name.chars().next_back() == Some('-'); +``` + +Use instead: +``` +name.ends_with('_') || name.ends_with('-'); +```
\ No newline at end of file |