2022-03-24 13:50:04 +00:00
|
|
|
error: called `map(..).flatten()` on `Option`
|
|
|
|
--> $DIR/map_flatten.rs:8:10
|
2018-10-06 16:18:06 +00:00
|
|
|
|
|
2022-03-24 13:50:04 +00:00
|
|
|
LL | .map(|x| {
|
|
|
|
| __________^
|
2023-07-28 19:35:48 +00:00
|
|
|
LL | |
|
|
|
|
LL | |
|
2022-03-24 13:50:04 +00:00
|
|
|
LL | | if x <= 5 {
|
|
|
|
... |
|
|
|
|
LL | | })
|
|
|
|
LL | | .flatten();
|
|
|
|
| |__________________^
|
2018-10-06 16:18:06 +00:00
|
|
|
|
|
|
|
|
= note: `-D clippy::map-flatten` implied by `-D warnings`
|
2022-06-19 19:21:14 +00:00
|
|
|
help: try replacing `map` with `and_then` and remove the `.flatten()`
|
2020-08-11 13:43:21 +00:00
|
|
|
|
|
2022-03-24 13:50:04 +00:00
|
|
|
LL ~ .and_then(|x| {
|
2023-07-28 19:35:48 +00:00
|
|
|
LL +
|
|
|
|
LL +
|
2022-03-24 13:50:04 +00:00
|
|
|
LL + if x <= 5 {
|
|
|
|
LL + Some(x)
|
2022-06-19 19:21:14 +00:00
|
|
|
LL + } else {
|
2022-03-24 13:50:04 +00:00
|
|
|
LL + None
|
|
|
|
LL + }
|
|
|
|
LL ~ });
|
2020-08-11 13:43:21 +00:00
|
|
|
|
|
|
|
|
|
2022-03-24 13:50:04 +00:00
|
|
|
error: called `map(..).flatten()` on `Result`
|
2023-07-28 19:35:48 +00:00
|
|
|
--> $DIR/map_flatten.rs:20:10
|
2022-03-24 13:50:04 +00:00
|
|
|
|
|
|
|
|
LL | .map(|x| {
|
|
|
|
| __________^
|
2023-07-28 19:35:48 +00:00
|
|
|
LL | |
|
2022-03-24 13:50:04 +00:00
|
|
|
LL | | if x == 1 {
|
|
|
|
LL | | Ok(x)
|
|
|
|
... |
|
|
|
|
LL | | })
|
|
|
|
LL | | .flatten();
|
|
|
|
| |__________________^
|
|
|
|
|
|
2022-06-19 19:21:14 +00:00
|
|
|
help: try replacing `map` with `and_then` and remove the `.flatten()`
|
2022-03-24 13:50:04 +00:00
|
|
|
|
|
|
|
|
LL ~ .and_then(|x| {
|
2023-07-28 19:35:48 +00:00
|
|
|
LL +
|
2022-03-24 13:50:04 +00:00
|
|
|
LL + if x == 1 {
|
|
|
|
LL + Ok(x)
|
2022-06-19 19:21:14 +00:00
|
|
|
LL + } else {
|
2022-03-24 13:50:04 +00:00
|
|
|
LL + Err(0)
|
|
|
|
LL + }
|
|
|
|
LL ~ });
|
2020-08-11 13:43:21 +00:00
|
|
|
|
|
|
|
|
|
2022-03-24 13:50:04 +00:00
|
|
|
error: called `map(..).flatten()` on `Result`
|
2023-07-28 19:35:48 +00:00
|
|
|
--> $DIR/map_flatten.rs:33:10
|
2022-03-24 13:50:04 +00:00
|
|
|
|
|
|
|
|
LL | .map(|res| {
|
|
|
|
| __________^
|
2023-07-28 19:35:48 +00:00
|
|
|
LL | |
|
2022-03-24 13:50:04 +00:00
|
|
|
LL | | if res > 0 {
|
|
|
|
LL | | do_something();
|
|
|
|
... |
|
|
|
|
LL | | })
|
|
|
|
LL | | .flatten();
|
|
|
|
| |__________________^
|
|
|
|
|
|
2022-06-19 19:21:14 +00:00
|
|
|
help: try replacing `map` with `and_then` and remove the `.flatten()`
|
2022-03-24 13:50:04 +00:00
|
|
|
|
|
|
|
|
LL ~ .and_then(|res| {
|
2023-07-28 19:35:48 +00:00
|
|
|
LL +
|
2022-03-24 13:50:04 +00:00
|
|
|
LL + if res > 0 {
|
|
|
|
LL + do_something();
|
2022-06-19 19:21:14 +00:00
|
|
|
LL + Ok(res)
|
|
|
|
LL + } else {
|
2022-03-24 13:50:04 +00:00
|
|
|
LL + Err(0)
|
|
|
|
LL + }
|
|
|
|
LL ~ });
|
2020-04-15 17:06:41 +00:00
|
|
|
|
|
|
|
|
|
2022-03-24 13:50:04 +00:00
|
|
|
error: called `map(..).flatten()` on `Iterator`
|
2023-07-28 19:35:48 +00:00
|
|
|
--> $DIR/map_flatten.rs:46:10
|
2022-03-24 13:50:04 +00:00
|
|
|
|
|
|
|
|
LL | .map(|some_value| {
|
|
|
|
| __________^
|
2023-07-28 19:35:48 +00:00
|
|
|
LL | |
|
2022-03-24 13:50:04 +00:00
|
|
|
LL | | if some_value > 3 {
|
|
|
|
LL | | Some(some_value)
|
|
|
|
... |
|
|
|
|
LL | | })
|
|
|
|
LL | | .flatten()
|
|
|
|
| |__________________^
|
|
|
|
|
|
2022-06-19 19:21:14 +00:00
|
|
|
help: try replacing `map` with `filter_map` and remove the `.flatten()`
|
2022-03-24 13:50:04 +00:00
|
|
|
|
|
|
|
|
LL ~ .filter_map(|some_value| {
|
2023-07-28 19:35:48 +00:00
|
|
|
LL +
|
2022-03-24 13:50:04 +00:00
|
|
|
LL + if some_value > 3 {
|
|
|
|
LL + Some(some_value)
|
2022-06-19 19:21:14 +00:00
|
|
|
LL + } else {
|
2022-03-24 13:50:04 +00:00
|
|
|
LL + None
|
|
|
|
LL + }
|
|
|
|
LL + })
|
2021-08-12 09:16:25 +00:00
|
|
|
|
|
|
|
|
|
2022-03-24 13:50:04 +00:00
|
|
|
error: aborting due to 4 previous errors
|
2018-09-21 07:26:38 +00:00
|
|
|
|