File tree Expand file tree Collapse file tree 3 files changed +24
-14
lines changed Expand file tree Collapse file tree 3 files changed +24
-14
lines changed Original file line number Diff line number Diff line change 1
1
// run-rustfix
2
2
3
+ #![allow(clippy::unnecessary_operation)]
3
4
#![warn(clippy::bytes_nth)]
4
5
5
6
fn main() {
6
- let _ = "Hello".as_bytes().get(3);
7
-
8
- let _ = String::from("Hello").as_bytes().get(3);
7
+ let s = String::from("String");
8
+ s.as_bytes().get(3);
9
+ &s.as_bytes().get(3);
10
+ s[..].as_bytes().get(3);
9
11
}
Original file line number Diff line number Diff line change 1
1
// run-rustfix
2
2
3
+ #![ allow( clippy:: unnecessary_operation) ]
3
4
#![ warn( clippy:: bytes_nth) ]
4
5
5
6
fn main ( ) {
6
- let _ = "Hello" . bytes ( ) . nth ( 3 ) ;
7
-
8
- let _ = String :: from ( "Hello" ) . bytes ( ) . nth ( 3 ) ;
7
+ let s = String :: from ( "String" ) ;
8
+ s. bytes ( ) . nth ( 3 ) ;
9
+ & s. bytes ( ) . nth ( 3 ) ;
10
+ s[ ..] . bytes ( ) . nth ( 3 ) ;
9
11
}
Original file line number Diff line number Diff line change 1
- error: called `.byte().nth()` on a `str `
2
- --> $DIR/bytes_nth.rs:6:13
1
+ error: called `.byte().nth()` on a `String `
2
+ --> $DIR/bytes_nth.rs:8:5
3
3
|
4
- LL | let _ = "Hello" .bytes().nth(3);
5
- | ^^^^^^^^^^^^^^^^^^^^^^ help: try calling `.as_bytes().get()` : `"Hello" .as_bytes().get(3)`
4
+ LL | s .bytes().nth(3);
5
+ | ^^^^^^^^^^^^^^^^ help: try: `s .as_bytes().get(3)`
6
6
|
7
7
= note: `-D clippy::bytes-nth` implied by `-D warnings`
8
8
9
9
error: called `.byte().nth()` on a `String`
10
- --> $DIR/bytes_nth.rs:8:13
10
+ --> $DIR/bytes_nth.rs:9:6
11
+ |
12
+ LL | &s.bytes().nth(3);
13
+ | ^^^^^^^^^^^^^^^^ help: try: `s.as_bytes().get(3)`
14
+
15
+ error: called `.byte().nth()` on a `str`
16
+ --> $DIR/bytes_nth.rs:10:5
11
17
|
12
- LL | let _ = String::from("Hello") .bytes().nth(3);
13
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try calling `.as_bytes().get()`: `String::from("Hello") .as_bytes().get(3)`
18
+ LL | s[..] .bytes().nth(3);
19
+ | ^^^^^^^^^^^^^^^^^^^^ help: try: `s[..] .as_bytes().get(3)`
14
20
15
- error: aborting due to 2 previous errors
21
+ error: aborting due to 3 previous errors
16
22
You can’t perform that action at this time.
0 commit comments