rust/src/docs/string_from_utf8_as_bytes.txt
2022-09-09 13:36:26 +02:00

15 lines
No EOL
297 B
Text

### What it does
Check if the string is transformed to byte array and casted back to string.
### Why is this bad?
It's unnecessary, the string can be used directly.
### Example
```
std::str::from_utf8(&"Hello World!".as_bytes()[6..11]).unwrap();
```
Use instead:
```
&"Hello World!"[6..11];
```