2020-05-17 10:36:26 -05:00
|
|
|
error: using `Option.and_then(|x| Some(y))`, which is more succinctly expressed as `map(|x| y)`
|
2022-06-04 06:34:07 -05:00
|
|
|
--> $DIR/bind_instead_of_map_multipart.rs:6:13
|
2020-05-17 10:36:26 -05:00
|
|
|
|
|
|
|
|
LL | let _ = Some("42").and_then(|s| if s.len() < 42 { Some(0) } else { Some(s.len()) });
|
|
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
|
|
|
|
note: the lint level is defined here
|
2022-06-04 06:34:07 -05:00
|
|
|
--> $DIR/bind_instead_of_map_multipart.rs:2:9
|
2020-05-17 10:36:26 -05:00
|
|
|
|
|
|
|
|
LL | #![deny(clippy::bind_instead_of_map)]
|
|
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
2023-07-01 06:08:01 -05:00
|
|
|
help: try
|
2020-05-17 10:36:26 -05:00
|
|
|
|
|
|
|
|
LL | let _ = Some("42").map(|s| if s.len() < 42 { 0 } else { s.len() });
|
2021-08-11 09:21:33 -05:00
|
|
|
| ~~~ ~ ~~~~~~~
|
2020-05-17 10:36:26 -05:00
|
|
|
|
|
|
|
error: using `Result.and_then(|x| Ok(y))`, which is more succinctly expressed as `map(|x| y)`
|
2022-06-04 06:34:07 -05:00
|
|
|
--> $DIR/bind_instead_of_map_multipart.rs:9:13
|
2020-05-17 10:36:26 -05:00
|
|
|
|
|
|
|
|
LL | let _ = Ok::<_, ()>("42").and_then(|s| if s.len() < 42 { Ok(0) } else { Ok(s.len()) });
|
|
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
|
2023-07-01 06:08:01 -05:00
|
|
|
help: try
|
2020-05-17 10:36:26 -05:00
|
|
|
|
|
|
|
|
LL | let _ = Ok::<_, ()>("42").map(|s| if s.len() < 42 { 0 } else { s.len() });
|
2021-08-11 09:21:33 -05:00
|
|
|
| ~~~ ~ ~~~~~~~
|
2020-05-17 10:36:26 -05:00
|
|
|
|
|
|
|
error: using `Result.or_else(|x| Err(y))`, which is more succinctly expressed as `map_err(|x| y)`
|
2022-06-04 06:34:07 -05:00
|
|
|
--> $DIR/bind_instead_of_map_multipart.rs:12:13
|
2020-05-17 10:36:26 -05:00
|
|
|
|
|
|
|
|
LL | let _ = Err::<(), _>("42").or_else(|s| if s.len() < 42 { Err(s.len() + 20) } else { Err(s.len()) });
|
|
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
|
2023-07-01 06:08:01 -05:00
|
|
|
help: try
|
2020-05-17 10:36:26 -05:00
|
|
|
|
|
|
|
|
LL | let _ = Err::<(), _>("42").map_err(|s| if s.len() < 42 { s.len() + 20 } else { s.len() });
|
2021-08-11 09:21:33 -05:00
|
|
|
| ~~~~~~~ ~~~~~~~~~~~~ ~~~~~~~
|
2020-05-17 10:36:26 -05:00
|
|
|
|
|
|
|
error: using `Option.and_then(|x| Some(y))`, which is more succinctly expressed as `map(|x| y)`
|
2022-06-04 06:34:07 -05:00
|
|
|
--> $DIR/bind_instead_of_map_multipart.rs:20:5
|
2020-05-17 10:36:26 -05:00
|
|
|
|
|
|
|
|
LL | / Some("42").and_then(|s| {
|
|
|
|
LL | | if {
|
|
|
|
LL | | if s == "43" {
|
|
|
|
LL | | return Some(43);
|
|
|
|
... |
|
|
|
|
LL | | }
|
|
|
|
LL | | });
|
|
|
|
| |______^
|
|
|
|
|
|
2023-07-01 06:08:01 -05:00
|
|
|
help: try
|
2020-05-17 10:36:26 -05:00
|
|
|
|
|
2021-08-11 09:21:33 -05:00
|
|
|
LL ~ Some("42").map(|s| {
|
2020-05-17 10:36:26 -05:00
|
|
|
LL | if {
|
|
|
|
LL | if s == "43" {
|
2021-08-11 09:21:33 -05:00
|
|
|
LL ~ return 43;
|
2020-05-17 10:36:26 -05:00
|
|
|
LL | }
|
|
|
|
LL | s == "42"
|
2022-06-16 09:00:32 -05:00
|
|
|
LL | } {
|
|
|
|
LL ~ return 45;
|
|
|
|
LL | }
|
|
|
|
LL | match s.len() {
|
|
|
|
LL ~ 10 => 2,
|
|
|
|
LL | 20 => {
|
2020-05-17 10:36:26 -05:00
|
|
|
...
|
2022-06-16 09:00:32 -05:00
|
|
|
LL | if foo() {
|
|
|
|
LL ~ return 20;
|
|
|
|
LL | }
|
|
|
|
LL | println!("foo");
|
|
|
|
LL ~ 3
|
|
|
|
LL | };
|
|
|
|
LL | }
|
|
|
|
LL ~ 20
|
|
|
|
LL | },
|
|
|
|
LL ~ 40 => 30,
|
|
|
|
LL ~ _ => 1,
|
|
|
|
|
|
2020-05-17 10:36:26 -05:00
|
|
|
|
|
|
|
error: using `Option.and_then(|x| Some(y))`, which is more succinctly expressed as `map(|x| y)`
|
2022-06-04 06:34:07 -05:00
|
|
|
--> $DIR/bind_instead_of_map_multipart.rs:61:13
|
2020-05-17 10:36:26 -05:00
|
|
|
|
|
|
|
|
LL | let _ = Some("").and_then(|s| if s.len() == 20 { Some(m!()) } else { Some(Some(20)) });
|
|
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
|
2023-07-01 06:08:01 -05:00
|
|
|
help: try
|
2020-05-17 10:36:26 -05:00
|
|
|
|
|
|
|
|
LL | let _ = Some("").map(|s| if s.len() == 20 { m!() } else { Some(20) });
|
2021-08-11 09:21:33 -05:00
|
|
|
| ~~~ ~~~~ ~~~~~~~~
|
2020-05-17 10:36:26 -05:00
|
|
|
|
|
|
|
error: aborting due to 5 previous errors
|
|
|
|
|