Skip to content

Commit 2d38163

Browse files
author
fmoko
authored
Merge pull request #492 from etiennebarrie/rustfmt-on-exercises
chore: Run rustfmt on exercises
2 parents d1054cd + 3144d3a commit 2d38163

File tree

12 files changed

+30
-25
lines changed

12 files changed

+30
-25
lines changed

exercises/conversions/from_str.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,5 +82,4 @@ mod tests {
8282
fn missing_name_and_invalid_age() {
8383
",one".parse::<Person>().unwrap();
8484
}
85-
8685
}

exercises/conversions/try_from_into.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Basically, this is the same as From. The main difference is that this should return a Result type
33
// instead of the target type itself.
44
// You can read more about it at https://doc.rust-lang.org/std/convert/trait.TryFrom.html
5-
use std::convert::{TryInto, TryFrom};
5+
use std::convert::{TryFrom, TryInto};
66

77
#[derive(Debug)]
88
struct Color {

exercises/conversions/using_as.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@
77
// I AM NOT DONE
88

99
fn average(values: &[f64]) -> f64 {
10-
let total = values
11-
.iter()
12-
.fold(0.0, |a, b| a + b);
10+
let total = values.iter().fold(0.0, |a, b| a + b);
1311
total / values.len()
1412
}
1513

exercises/enums/enums2.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ impl Message {
1616

1717
fn main() {
1818
let messages = [
19-
Message::Move{ x: 10, y: 30 },
19+
Message::Move { x: 10, y: 30 },
2020
Message::Echo(String::from("hello world")),
2121
Message::ChangeColor(200, 255, 255),
22-
Message::Quit
22+
Message::Quit,
2323
];
2424

2525
for message in &messages {

exercises/enums/enums3.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ enum Message {
99

1010
struct Point {
1111
x: u8,
12-
y: u8
12+
y: u8,
1313
}
1414

1515
struct State {
1616
color: (u8, u8, u8),
1717
position: Point,
18-
quit: bool
18+
quit: bool,
1919
}
2020

2121
impl State {
@@ -46,20 +46,19 @@ mod tests {
4646

4747
#[test]
4848
fn test_match_message_call() {
49-
let mut state = State{
49+
let mut state = State {
5050
quit: false,
51-
position: Point{ x: 0, y: 0 },
52-
color: (0, 0, 0)
51+
position: Point { x: 0, y: 0 },
52+
color: (0, 0, 0),
5353
};
5454
state.process(Message::ChangeColor((255, 0, 255)));
5555
state.process(Message::Echo(String::from("hello world")));
56-
state.process(Message::Move(Point{ x: 10, y: 15 }));
56+
state.process(Message::Move(Point { x: 10, y: 15 }));
5757
state.process(Message::Quit);
5858

5959
assert_eq!(state.color, (255, 0, 255));
6060
assert_eq!(state.position.x, 10);
6161
assert_eq!(state.position.y, 15);
6262
assert_eq!(state.quit, true);
6363
}
64-
6564
}

exercises/generics/generics1.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,3 @@ fn main() {
77
let mut shopping_list: Vec<?> = Vec::new();
88
shopping_list.push("milk");
99
}
10-

exercises/generics/generics2.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// I AM NOT DONE
55

66
struct Wrapper {
7-
value: u32
7+
value: u32,
88
}
99

1010
impl Wrapper {

exercises/generics/generics3.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@ mod tests {
3333
student_name: "Tom Wriggle".to_string(),
3434
student_age: 12,
3535
};
36-
assert_eq!(report_card.print(), "Tom Wriggle (12) - achieved a grade of 2.1");
36+
assert_eq!(
37+
report_card.print(),
38+
"Tom Wriggle (12) - achieved a grade of 2.1"
39+
);
3740
}
3841

3942
#[test]
@@ -44,6 +47,9 @@ mod tests {
4447
student_name: "Gary Plotter".to_string(),
4548
student_age: 11,
4649
};
47-
assert_eq!(report_card.print(), "Gary Plotter (11) - achieved a grade of A+");
50+
assert_eq!(
51+
report_card.print(),
52+
"Gary Plotter (11) - achieved a grade of A+"
53+
);
4854
}
4955
}

exercises/macros/macros4.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
macro_rules! my_macro {
77
() => {
88
println!("Check out my macro!");
9-
}
9+
};
1010
($val:expr) => {
1111
println!("Look at this other macro: {}", $val);
12-
}
12+
};
1313
}
1414

1515
fn main() {

exercises/standard_library_types/box1.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@ pub enum List {
2626

2727
fn main() {
2828
println!("This is an empty cons list: {:?}", create_empty_list());
29-
println!("This is a non-empty cons list: {:?}", create_non_empty_list());
29+
println!(
30+
"This is a non-empty cons list: {:?}",
31+
create_non_empty_list()
32+
);
3033
}
3134

3235
pub fn create_empty_list() -> List {

0 commit comments

Comments
 (0)