]> git.lizzy.rs Git - rust.git/blob - src/docs/string_slice.txt
[Arithmetic] Consider literals
[rust.git] / src / docs / string_slice.txt
1 ### What it does
2 Checks for slice operations on strings
3
4 ### Why is this bad?
5 UTF-8 characters span multiple bytes, and it is easy to inadvertently confuse character
6 counts and string indices. This may lead to panics, and should warrant some test cases
7 containing wide UTF-8 characters. This lint is most useful in code that should avoid
8 panics at all costs.
9
10 ### Known problems
11 Probably lots of false positives. If an index comes from a known valid position (e.g.
12 obtained via `char_indices` over the same string), it is totally OK.
13
14 # Example
15 ```
16 &"Ölkanne"[1..];
17 ```