]> git.lizzy.rs Git - rust.git/blob - src/docs/useless_asref.txt
[Arithmetic] Consider literals
[rust.git] / src / docs / useless_asref.txt
1 ### What it does
2 Checks for usage of `.as_ref()` or `.as_mut()` where the
3 types before and after the call are the same.
4
5 ### Why is this bad?
6 The call is unnecessary.
7
8 ### Example
9 ```
10 let x: &[i32] = &[1, 2, 3, 4, 5];
11 do_stuff(x.as_ref());
12 ```
13 The correct use would be:
14 ```
15 let x: &[i32] = &[1, 2, 3, 4, 5];
16 do_stuff(x);
17 ```