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