Skip to content

Commit 6b7e0e1

Browse files
committed
format all exercises
1 parent 9cacd5a commit 6b7e0e1

File tree

21 files changed

+179
-128
lines changed

21 files changed

+179
-128
lines changed

exercises/acronym/tests/acronym.rs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@ fn punctuation() {
3030
#[test]
3131
#[ignore]
3232
fn all_caps_word() {
33-
assert_eq!(acronym::abbreviate("GNU Image Manipulation Program"), "GIMP");
33+
assert_eq!(
34+
acronym::abbreviate("GNU Image Manipulation Program"),
35+
"GIMP"
36+
);
3437
}
3538

3639
#[test]
@@ -52,7 +55,9 @@ fn punctuation_without_whitespace() {
5255
#[ignore]
5356
fn very_long_abbreviation() {
5457
assert_eq!(
55-
acronym::abbreviate("Rolling On The Floor Laughing So Hard That My Dogs Came Over And Licked Me"),
58+
acronym::abbreviate(
59+
"Rolling On The Floor Laughing So Hard That My Dogs Came Over And Licked Me"
60+
),
5661
"ROTFLSHTMDCOALM"
5762
);
5863
}
@@ -69,17 +74,11 @@ fn consecutive_delimiters() {
6974
#[test]
7075
#[ignore]
7176
fn apostrophes() {
72-
assert_eq!(
73-
acronym::abbreviate("Halley's Comet"),
74-
"HC"
75-
);
77+
assert_eq!(acronym::abbreviate("Halley's Comet"), "HC");
7678
}
7779

7880
#[test]
7981
#[ignore]
8082
fn underscore_emphasis() {
81-
assert_eq!(
82-
acronym::abbreviate("The Road _Not_ Taken"),
83-
"TRNT"
84-
);
83+
assert_eq!(acronym::abbreviate("The Road _Not_ Taken"), "TRNT");
8584
}

exercises/all-your-base/example.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ pub fn convert<P: AsRef<[Digit]>>(
5555
if let Some(&invalid) = digits.as_ref().iter().find(|&num| *num >= from_base) {
5656
return Err(Error::InvalidDigit(invalid));
5757
}
58-
58+
5959
// convert all digits into a single large number
6060
let mut immediate: Digit = digits
6161
.as_ref()
@@ -75,6 +75,6 @@ pub fn convert<P: AsRef<[Digit]>>(
7575
res.reverse();
7676
if res.is_empty() {
7777
res.push(0);
78-
}
78+
}
7979
Ok(res)
8080
}

exercises/bob/tests/bob.rs

Lines changed: 17 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -8,196 +8,183 @@ fn test_stating_something() {
88
process_response_case("Tom-ay-to, tom-aaaah-to.", "Whatever.");
99
}
1010

11-
1211
#[test]
1312
#[ignore]
1413
/// ending with whitespace
1514
fn test_ending_with_whitespace() {
1615
process_response_case("Okay if like my spacebar quite a bit? ", "Sure.");
1716
}
1817

19-
2018
#[test]
2119
#[ignore]
2220
/// shouting numbers
2321
fn test_shouting_numbers() {
2422
process_response_case("1, 2, 3 GO!", "Whoa, chill out!");
2523
}
2624

27-
2825
#[test]
2926
#[ignore]
3027
/// other whitespace
3128
fn test_other_whitespace() {
3229
process_response_case("\r\r ", "Fine. Be that way!");
3330
}
3431

35-
3632
#[test]
3733
#[ignore]
3834
/// shouting with special characters
3935
fn test_shouting_with_special_characters() {
40-
process_response_case("ZOMG THE %^*@#$(*^ ZOMBIES ARE COMING!!11!!1!", "Whoa, chill out!");
36+
process_response_case(
37+
"ZOMG THE %^*@#$(*^ ZOMBIES ARE COMING!!11!!1!",
38+
"Whoa, chill out!",
39+
);
4140
}
4241

43-
4442
#[test]
4543
#[ignore]
4644
/// talking forcefully
4745
fn test_talking_forcefully() {
4846
process_response_case("Hi there!", "Whatever.");
4947
}
5048

51-
5249
#[test]
5350
#[ignore]
5451
/// prattling on
5552
fn test_prattling_on() {
5653
process_response_case("Wait! Hang on. Are you going to be OK?", "Sure.");
5754
}
5855

59-
6056
#[test]
6157
#[ignore]
6258
/// forceful question
6359
fn test_forceful_question() {
64-
process_response_case("WHAT'S GOING ON?", "Calm down, I know what I'm doing!");
60+
process_response_case("WHAT'S GOING ON?", "Calm down, I know what I'm doing!");
6561
}
6662

67-
6863
#[test]
6964
#[ignore]
7065
/// shouting with no exclamation mark
7166
fn test_shouting_with_no_exclamation_mark() {
7267
process_response_case("I HATE THE DENTIST", "Whoa, chill out!");
7368
}
7469

75-
7670
#[test]
7771
#[ignore]
7872
/// asking gibberish
7973
fn test_asking_gibberish() {
8074
process_response_case("fffbbcbeab?", "Sure.");
8175
}
8276

83-
8477
#[test]
8578
#[ignore]
8679
/// question with no letters
8780
fn test_question_with_no_letters() {
8881
process_response_case("4?", "Sure.");
8982
}
9083

91-
9284
#[test]
9385
#[ignore]
9486
/// no letters
9587
fn test_no_letters() {
9688
process_response_case("1, 2, 3", "Whatever.");
9789
}
9890

99-
10091
#[test]
10192
#[ignore]
10293
/// statement containing question mark
10394
fn test_statement_containing_question_mark() {
10495
process_response_case("Ending with ? means a question.", "Whatever.");
10596
}
10697

107-
10898
//NEW
10999
#[test]
110100
#[ignore]
111101
/// multiple line question
112102
fn test_multiple_line_question() {
113-
process_response_case("\rDoes this cryogenic chamber make me look fat?\rNo.", "Whatever.");
103+
process_response_case(
104+
"\rDoes this cryogenic chamber make me look fat?\rNo.",
105+
"Whatever.",
106+
);
114107
}
115108

116-
117109
#[test]
118110
#[ignore]
119111
/// non-question ending with whitespace
120112
fn test_nonquestion_ending_with_whitespace() {
121-
process_response_case("This is a statement ending with whitespace ", "Whatever.");
113+
process_response_case(
114+
"This is a statement ending with whitespace ",
115+
"Whatever.",
116+
);
122117
}
123118

124-
125119
#[test]
126120
#[ignore]
127121
/// shouting
128122
fn test_shouting() {
129123
process_response_case("WATCH OUT!", "Whoa, chill out!");
130124
}
131125

132-
133126
#[test]
134127
#[ignore]
135128
/// non-letters with question
136129
fn test_nonletters_with_question() {
137130
process_response_case(":) ?", "Sure.");
138131
}
139132

140-
141133
#[test]
142134
#[ignore]
143135
/// shouting gibberish
144136
fn test_shouting_gibberish() {
145137
process_response_case("FCECDFCAAB", "Whoa, chill out!");
146138
}
147139

148-
149140
#[test]
150141
#[ignore]
151142
/// asking a question
152143
fn test_asking_a_question() {
153144
process_response_case("Does this cryogenic chamber make me look fat?", "Sure.");
154145
}
155146

156-
157147
#[test]
158148
#[ignore]
159149
/// asking a numeric question
160150
fn test_asking_a_numeric_question() {
161151
process_response_case("You are, what, like 15?", "Sure.");
162152
}
163153

164-
165154
#[test]
166155
#[ignore]
167156
/// silence
168157
fn test_silence() {
169158
process_response_case("", "Fine. Be that way!");
170159
}
171160

172-
173161
#[test]
174162
#[ignore]
175163
/// starting with whitespace
176164
fn test_starting_with_whitespace() {
177165
process_response_case(" hmmmmmmm...", "Whatever.");
178166
}
179167

180-
181168
#[test]
182169
#[ignore]
183170
/// using acronyms in regular speech
184171
fn test_using_acronyms_in_regular_speech() {
185-
process_response_case("It's OK if you don't want to go work for NASA.", "Whatever.");
172+
process_response_case(
173+
"It's OK if you don't want to go work for NASA.",
174+
"Whatever.",
175+
);
186176
}
187177

188-
189178
#[test]
190179
#[ignore]
191180
/// alternate silence
192181
fn test_alternate_silence() {
193182
process_response_case(" ", "Fine. Be that way!");
194183
}
195184

196-
197185
#[test]
198186
#[ignore]
199187
/// prolonged silence
200188
fn test_prolonged_silence() {
201189
process_response_case(" ", "Fine. Be that way!");
202190
}
203-

exercises/bowling/tests/bowling.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,6 @@ fn cannot_roll_after_bonus_roll_for_strike() {
432432
assert_eq!(game.roll(2), Err(Error::GameComplete));
433433
}
434434

435-
436435
#[test]
437436
#[ignore]
438437
fn last_two_strikes_followed_by_only_last_bonus_with_non_strike_points() {

exercises/decimal/example.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ impl Decimal {
7676
lower_precision.decimal_index += precision_difference;
7777
}
7878
match one.decimal_index.cmp(&two.decimal_index) {
79-
std::cmp::Ordering::Equal => {},
79+
std::cmp::Ordering::Equal => {}
8080
std::cmp::Ordering::Less => expand(&mut one, &two),
8181
std::cmp::Ordering::Greater => expand(&mut two, &one),
8282
}
@@ -118,7 +118,13 @@ macro_rules! auto_impl_decimal_ops {
118118

119119
auto_impl_decimal_ops!(Add, add, |s, o| s + o, |s, _| s);
120120
auto_impl_decimal_ops!(Sub, sub, |s, o| s - o, |s, _| s);
121-
auto_impl_decimal_ops!(#[allow(clippy::suspicious_arithmetic_impl)] Mul, mul, |s, o| s * o, |s, o| s + o);
121+
auto_impl_decimal_ops!(
122+
#[allow(clippy::suspicious_arithmetic_impl)]
123+
Mul,
124+
mul,
125+
|s, o| s * o,
126+
|s, o| s + o
127+
);
122128

123129
macro_rules! auto_impl_decimal_cow {
124130
($trait:ident, $func_name:ident, $digits_operation:expr, $return_type:ty) => {

exercises/dot-dsl/example.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ pub mod graph {
104104
self.attrs.get(name).map(|v| v.as_ref())
105105
}
106106
}
107-
108107
}
109108
}
110109
}

exercises/forth/example.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,12 @@ impl Forth {
172172
for t in code.iter() {
173173
match t {
174174
Term::Number(_) => resolved_def.push_back(t.clone()),
175-
Term::Word(s) => if let Some(cs) = self.defs.get(s) {
176-
resolved_def.append(&mut cs.clone());
177-
} else {
178-
resolved_def.push_back(t.clone());
175+
Term::Word(s) => {
176+
if let Some(cs) = self.defs.get(s) {
177+
resolved_def.append(&mut cs.clone());
178+
} else {
179+
resolved_def.push_back(t.clone());
180+
}
179181
}
180182
_ => {
181183
eprintln!("Nested definition in {}", name);

exercises/forth/tests/forth.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,4 +359,3 @@ fn definitions_after_ops() {
359359
assert!(f.eval("1 2 + : addone 1 + ; addone").is_ok());
360360
assert_eq!(vec![4], f.stack());
361361
}
362-

exercises/minesweeper/example.rs

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
struct Board {
22
pieces: Vec<Vec<char>>,
33
num_rows: usize,
4-
num_cols: usize
4+
num_cols: usize,
55
}
66

77
impl Board {
@@ -11,10 +11,16 @@ impl Board {
1111

1212
fn annotated_row(&self, y: usize) -> String {
1313
self.pieces[y]
14-
.iter()
15-
.enumerate()
16-
.map(|(x,&c)| if c == ' ' {self.count_neighbouring_mines_char(x, y)} else {c})
17-
.collect::<String>()
14+
.iter()
15+
.enumerate()
16+
.map(|(x, &c)| {
17+
if c == ' ' {
18+
self.count_neighbouring_mines_char(x, y)
19+
} else {
20+
c
21+
}
22+
})
23+
.collect::<String>()
1824
}
1925

2026
fn count_neighbouring_mines_char(&self, x: usize, y: usize) -> char {
@@ -40,16 +46,21 @@ pub fn annotate(pieces: &[&str]) -> Vec<String> {
4046
return Vec::new();
4147
}
4248
let pieces_vec = pieces.iter().map(|&r| r.chars().collect()).collect();
43-
Board {pieces: pieces_vec, num_rows: pieces.len(), num_cols: pieces[0].len()}.annotated()
49+
Board {
50+
pieces: pieces_vec,
51+
num_rows: pieces.len(),
52+
num_cols: pieces[0].len(),
53+
}
54+
.annotated()
4455
}
4556

4657
fn neighbouring_points(x: usize, limit: usize) -> Vec<usize> {
4758
let mut offsets = vec![x];
4859
if x >= 1 {
49-
offsets.push(x-1);
60+
offsets.push(x - 1);
5061
}
51-
if x+2 <= limit {
52-
offsets.push(x+1);
62+
if x + 2 <= limit {
63+
offsets.push(x + 1);
5364
}
5465
offsets
5566
}

0 commit comments

Comments
 (0)