]> git.lizzy.rs Git - rust.git/blob - src/docs/get_first.txt
[Arithmetic] Consider literals
[rust.git] / src / docs / get_first.txt
1 ### What it does
2 Checks for using `x.get(0)` instead of
3 `x.first()`.
4
5 ### Why is this bad?
6 Using `x.first()` is easier to read and has the same
7 result.
8
9 ### Example
10 ```
11 let x = vec![2, 3, 5];
12 let first_element = x.get(0);
13 ```
14
15 Use instead:
16 ```
17 let x = vec![2, 3, 5];
18 let first_element = x.first();
19 ```