mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-23 13:13:34 +00:00
add #[must_use] to functions of slice and its iterators.
This commit is contained in:
parent
96f4e1c630
commit
41f1413085
2 changed files with 18 additions and 18 deletions
|
@ -1,8 +1,8 @@
|
|||
error: called `.byte().nth()` on a `String`
|
||||
--> $DIR/bytes_nth.rs:8:5
|
||||
--> $DIR/bytes_nth.rs:8:13
|
||||
|
|
||||
LL | s.bytes().nth(3);
|
||||
| ^^^^^^^^^^^^^^^^ help: try: `s.as_bytes().get(3)`
|
||||
LL | let _ = s.bytes().nth(3);
|
||||
| ^^^^^^^^^^^^^^^^ help: try: `s.as_bytes().get(3)`
|
||||
|
|
||||
= note: `-D clippy::bytes-nth` implied by `-D warnings`
|
||||
|
||||
|
@ -13,10 +13,10 @@ LL | let _ = &s.bytes().nth(3);
|
|||
| ^^^^^^^^^^^^^^^^ help: try: `s.as_bytes().get(3)`
|
||||
|
||||
error: called `.byte().nth()` on a `str`
|
||||
--> $DIR/bytes_nth.rs:10:5
|
||||
--> $DIR/bytes_nth.rs:10:13
|
||||
|
|
||||
LL | s[..].bytes().nth(3);
|
||||
| ^^^^^^^^^^^^^^^^^^^^ help: try: `s[..].as_bytes().get(3)`
|
||||
LL | let _ = s[..].bytes().nth(3);
|
||||
| ^^^^^^^^^^^^^^^^^^^^ help: try: `s[..].as_bytes().get(3)`
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
|
|
|
@ -1,28 +1,28 @@
|
|||
error: using `.iter().next()` on an array
|
||||
--> $DIR/iter_next_slice.rs:9:5
|
||||
--> $DIR/iter_next_slice.rs:9:13
|
||||
|
|
||||
LL | s.iter().next();
|
||||
| ^^^^^^^^^^^^^^^ help: try calling: `s.get(0)`
|
||||
LL | let _ = s.iter().next();
|
||||
| ^^^^^^^^^^^^^^^ help: try calling: `s.get(0)`
|
||||
|
|
||||
= note: `-D clippy::iter-next-slice` implied by `-D warnings`
|
||||
|
||||
error: using `.iter().next()` on a Slice without end index
|
||||
--> $DIR/iter_next_slice.rs:12:5
|
||||
--> $DIR/iter_next_slice.rs:12:13
|
||||
|
|
||||
LL | s[2..].iter().next();
|
||||
| ^^^^^^^^^^^^^^^^^^^^ help: try calling: `s.get(2)`
|
||||
LL | let _ = s[2..].iter().next();
|
||||
| ^^^^^^^^^^^^^^^^^^^^ help: try calling: `s.get(2)`
|
||||
|
||||
error: using `.iter().next()` on a Slice without end index
|
||||
--> $DIR/iter_next_slice.rs:15:5
|
||||
--> $DIR/iter_next_slice.rs:15:13
|
||||
|
|
||||
LL | v[5..].iter().next();
|
||||
| ^^^^^^^^^^^^^^^^^^^^ help: try calling: `v.get(5)`
|
||||
LL | let _ = v[5..].iter().next();
|
||||
| ^^^^^^^^^^^^^^^^^^^^ help: try calling: `v.get(5)`
|
||||
|
||||
error: using `.iter().next()` on an array
|
||||
--> $DIR/iter_next_slice.rs:18:5
|
||||
--> $DIR/iter_next_slice.rs:18:13
|
||||
|
|
||||
LL | v.iter().next();
|
||||
| ^^^^^^^^^^^^^^^ help: try calling: `v.get(0)`
|
||||
LL | let _ = v.iter().next();
|
||||
| ^^^^^^^^^^^^^^^ help: try calling: `v.get(0)`
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
|
|
Loading…
Reference in a new issue