Skip to content

Commit ccdf8f0

Browse files
committed
rustfmt tests
1 parent f3f168e commit ccdf8f0

File tree

4 files changed

+30
-38
lines changed

4 files changed

+30
-38
lines changed

tests/ui/filter_map_next.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
fn main() {
44
let a = ["1", "lol", "3", "NaN", "5"];
55

6-
let element : Option<i32> = a.iter().filter_map(|s| s.parse().ok()).next();
6+
let element: Option<i32> = a.iter().filter_map(|s| s.parse().ok()).next();
77
assert_eq!(element, Some(1));
8-
}
8+
}

tests/ui/filter_map_next.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error: called `filter_map(p).next()` on an `Iterator`. This is more succinctly expressed by calling `.find_map(p)` instead.
2-
--> $DIR/filter_map_next.rs:6:33
2+
--> $DIR/filter_map_next.rs:6:32
33
|
4-
LL | let element : Option<i32> = a.iter().filter_map(|s| s.parse().ok()).next();
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4+
LL | let element: Option<i32> = a.iter().filter_map(|s| s.parse().ok()).next();
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66
|
77
= note: `-D clippy::filter-map-next` implied by `-D warnings`
88
= note: replace `filter_map(|s| s.parse().ok()).next()` with `find_map(|s| s.parse().ok())`

tests/ui/find_map.rs

+14-20
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,32 @@
11
#![warn(clippy::all, clippy::pedantic)]
22

3-
#[derive(Debug,Copy,Clone)]
3+
#[derive(Debug, Copy, Clone)]
44
enum Flavor {
55
Chocolate,
66
}
77

8-
#[derive(Debug,Copy,Clone)]
8+
#[derive(Debug, Copy, Clone)]
99
enum Dessert {
1010
Banana,
1111
Pudding,
12-
Cake(Flavor)
12+
Cake(Flavor),
1313
}
1414

1515
fn main() {
16-
let desserts_of_the_week = vec![
17-
Dessert::Banana,
18-
Dessert::Cake(Flavor::Chocolate),
19-
Dessert::Pudding,
20-
];
16+
let desserts_of_the_week = vec![Dessert::Banana, Dessert::Cake(Flavor::Chocolate), Dessert::Pudding];
2117

2218
let a = ["lol", "NaN", "2", "5", "Xunda"];
2319

24-
let _ : Option<i32> = a.iter().find(|s| s.parse::<i32>().is_ok())
25-
.map(|s| s.parse().unwrap());
20+
let _: Option<i32> = a.iter().find(|s| s.parse::<i32>().is_ok()).map(|s| s.parse().unwrap());
2621

27-
let _ : Option<Flavor> = desserts_of_the_week.iter().find(|dessert|{
28-
match *dessert {
22+
let _: Option<Flavor> = desserts_of_the_week
23+
.iter()
24+
.find(|dessert| match *dessert {
2925
Dessert::Cake(_) => true,
30-
_ => false
31-
}
32-
}).map(|dessert|{
33-
match *dessert {
26+
_ => false,
27+
})
28+
.map(|dessert| match *dessert {
3429
Dessert::Cake(ref flavor) => *flavor,
35-
_ => unreachable!()
36-
}
37-
});
38-
}
30+
_ => unreachable!(),
31+
});
32+
}

tests/ui/find_map.stderr

+11-13
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,23 @@
11
error: called `find(p).map(q)` on an `Iterator`. This is more succinctly expressed by calling `.find_map(..)` instead.
2-
--> $DIR/find_map.rs:24:27
2+
--> $DIR/find_map.rs:20:26
33
|
4-
LL | let _ : Option<i32> = a.iter().find(|s| s.parse::<i32>().is_ok())
5-
| ___________________________^
6-
LL | | .map(|s| s.parse().unwrap());
7-
| |______________________________________________________________^
4+
LL | let _: Option<i32> = a.iter().find(|s| s.parse::<i32>().is_ok()).map(|s| s.parse().unwrap());
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
86
|
97
= note: `-D clippy::find-map` implied by `-D warnings`
108

119
error: called `find(p).map(q)` on an `Iterator`. This is more succinctly expressed by calling `.find_map(..)` instead.
12-
--> $DIR/find_map.rs:27:30
10+
--> $DIR/find_map.rs:22:29
1311
|
14-
LL | let _ : Option<Flavor> = desserts_of_the_week.iter().find(|dessert|{
15-
| ______________________________^
16-
LL | | match *dessert {
12+
LL | let _: Option<Flavor> = desserts_of_the_week
13+
| _____________________________^
14+
LL | | .iter()
15+
LL | | .find(|dessert| match *dessert {
1716
LL | | Dessert::Cake(_) => true,
18-
LL | | _ => false
1917
... |
20-
LL | | }
21-
LL | | });
22-
| |______^
18+
LL | | _ => unreachable!(),
19+
LL | | });
20+
| |__________^
2321

2422
error: aborting due to 2 previous errors
2523

0 commit comments

Comments
 (0)