add #[must_use] to functions of slice and its iterators.

This commit is contained in:
Jendrik 2022-03-26 16:19:47 +01:00
parent 96f4e1c630
commit 41f1413085
2 changed files with 18 additions and 18 deletions

View file

@ -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

View file

@ -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