Skip to content

Commit fffbb60

Browse files
committed
Auto merge of #161 - c-rustacean:rustfmt-and-ws-fixes, r=komaeda
Rustfmt and ws fixes
2 parents 5a9f886 + 9aec4ab commit fffbb60

File tree

8 files changed

+54
-18
lines changed

8 files changed

+54
-18
lines changed

exercises/error_handling/errors2.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,7 @@ mod tests {
3232

3333
#[test]
3434
fn item_quantity_is_a_valid_number() {
35-
assert_eq!(
36-
total_cost("34"),
37-
Ok(171)
38-
);
35+
assert_eq!(total_cost("34"), Ok(171));
3936
}
4037

4138
#[test]

exercises/error_handling/errorsn.rs

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ fn test_ioerror() {
6565
assert_eq!("uh-oh!", read_and_validate(&mut b).unwrap_err().to_string());
6666
}
6767

68-
#[derive(PartialEq,Debug)]
68+
#[derive(PartialEq, Debug)]
6969
struct PositiveNonzeroInteger(u64);
7070

7171
impl PositiveNonzeroInteger {
@@ -83,11 +83,14 @@ impl PositiveNonzeroInteger {
8383
#[test]
8484
fn test_positive_nonzero_integer_creation() {
8585
assert!(PositiveNonzeroInteger::new(10).is_ok());
86-
assert_eq!(Err(CreationError::Negative), PositiveNonzeroInteger::new(-10));
86+
assert_eq!(
87+
Err(CreationError::Negative),
88+
PositiveNonzeroInteger::new(-10)
89+
);
8790
assert_eq!(Err(CreationError::Zero), PositiveNonzeroInteger::new(0));
8891
}
8992

90-
#[derive(PartialEq,Debug)]
93+
#[derive(PartialEq, Debug)]
9194
enum CreationError {
9295
Negative,
9396
Zero,
@@ -108,6 +111,36 @@ impl error::Error for CreationError {
108111
}
109112
}
110113

114+
115+
116+
117+
118+
119+
120+
121+
122+
123+
124+
125+
126+
127+
128+
129+
130+
131+
132+
133+
134+
135+
136+
137+
138+
139+
140+
141+
142+
143+
111144
// First hint: To figure out what type should go where the ??? is, take a look
112145
// at the test helper function `test_with_str`, since it returns whatever
113146
// `read_and_validate` returns and`test_with_str` has its signature fully

exercises/error_handling/option1.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ fn main() {
1111
println!("The last item in the list is {:?}", last);
1212

1313
let second_to_last = list.pop().unwrap();
14-
println!("The second-to-last item in the list is {:?}", second_to_last);
14+
println!(
15+
"The second-to-last item in the list is {:?}",
16+
second_to_last
17+
);
1518
}
1619

1720

exercises/error_handling/result1.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
// result1.rs
22
// Make this test pass! Scroll down for hints :)
33

4-
#[derive(PartialEq,Debug)]
4+
#[derive(PartialEq, Debug)]
55
struct PositiveNonzeroInteger(u64);
66

7-
#[derive(PartialEq,Debug)]
7+
#[derive(PartialEq, Debug)]
88
enum CreationError {
99
Negative,
1010
Zero,
@@ -19,7 +19,10 @@ impl PositiveNonzeroInteger {
1919
#[test]
2020
fn test_creation() {
2121
assert!(PositiveNonzeroInteger::new(10).is_ok());
22-
assert_eq!(Err(CreationError::Negative), PositiveNonzeroInteger::new(-10));
22+
assert_eq!(
23+
Err(CreationError::Negative),
24+
PositiveNonzeroInteger::new(-10)
25+
);
2326
assert_eq!(Err(CreationError::Zero), PositiveNonzeroInteger::new(0));
2427
}
2528

exercises/standard_library_types/iterator3.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ mod tests {
114114

115115

116116

117-
// Minor hint: In each of the two cases in the match in main, you can create x with either
117+
// Minor hint: In each of the two cases in the match in main, you can create x with either
118118
// a 'turbofish' or by hinting the type of x to the compiler. You may try both.
119119

120120

@@ -143,5 +143,5 @@ mod tests {
143143

144144

145145

146-
// Major hint: Have a look at the Iter trait and at the explanation of its collect function.
146+
// Major hint: Have a look at the Iter trait and at the explanation of its collect function.
147147
// Especially the part about Result is interesting.

src/exercise.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use serde::Deserialize;
22
use std::fmt::{self, Display, Formatter};
3-
use std::fs::{remove_file};
4-
use std::path::{PathBuf};
3+
use std::fs::remove_file;
4+
use std::path::PathBuf;
55
use std::process::{self, Command, Output};
66

77
const RUSTC_COLOR_ARGS: &[&str] = &["--color", "always"];
@@ -63,8 +63,8 @@ impl Display for Exercise {
6363
#[cfg(test)]
6464
mod test {
6565
use super::*;
66-
use std::path::Path;
6766
use std::fs::File;
67+
use std::path::Path;
6868

6969
#[test]
7070
fn test_clean() {

src/run.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::exercise::{Mode, Exercise};
1+
use crate::exercise::{Exercise, Mode};
22
use crate::verify::test;
33
use console::{style, Emoji};
44
use indicatif::ProgressBar;

src/verify.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::exercise::{Exercise, Mode};
22
use console::{style, Emoji};
33
use indicatif::ProgressBar;
44

5-
pub fn verify<'a>(start_at: impl IntoIterator<Item=&'a Exercise>) -> Result<(), ()> {
5+
pub fn verify<'a>(start_at: impl IntoIterator<Item = &'a Exercise>) -> Result<(), ()> {
66
for exercise in start_at {
77
match exercise.mode {
88
Mode::Test => test(&exercise)?,

0 commit comments

Comments
 (0)