summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2019-05-22 12:29:20 +0000
committerbors <bors@rust-lang.org>2019-05-22 12:29:20 +0000
commitfffbb60ed92bbe83b9706a07080216f0549265c0 (patch)
tree0cc4942f65fe06f337208094c93763a8d63a5cf8
parent5a9f8860caf4c9b9ed6f227ac460f2809baedb3a (diff)
parent9aec4abc4d1edb9eacf86c4152675aeddb30694d (diff)
Auto merge of #161 - c-rustacean:rustfmt-and-ws-fixes, r=komaeda
Rustfmt and ws fixes
-rw-r--r--exercises/error_handling/errors2.rs5
-rw-r--r--exercises/error_handling/errorsn.rs39
-rw-r--r--exercises/error_handling/option1.rs5
-rw-r--r--exercises/error_handling/result1.rs9
-rw-r--r--exercises/standard_library_types/iterator3.rs4
-rw-r--r--src/exercise.rs6
-rw-r--r--src/run.rs2
-rw-r--r--src/verify.rs2
8 files changed, 54 insertions, 18 deletions
diff --git a/exercises/error_handling/errors2.rs b/exercises/error_handling/errors2.rs
index d97f3b7..8b81207 100644
--- a/exercises/error_handling/errors2.rs
+++ b/exercises/error_handling/errors2.rs
@@ -32,10 +32,7 @@ mod tests {
#[test]
fn item_quantity_is_a_valid_number() {
- assert_eq!(
- total_cost("34"),
- Ok(171)
- );
+ assert_eq!(total_cost("34"), Ok(171));
}
#[test]
diff --git a/exercises/error_handling/errorsn.rs b/exercises/error_handling/errorsn.rs
index 15c6cd5..8d39967 100644
--- a/exercises/error_handling/errorsn.rs
+++ b/exercises/error_handling/errorsn.rs
@@ -65,7 +65,7 @@ fn test_ioerror() {
assert_eq!("uh-oh!", read_and_validate(&mut b).unwrap_err().to_string());
}
-#[derive(PartialEq,Debug)]
+#[derive(PartialEq, Debug)]
struct PositiveNonzeroInteger(u64);
impl PositiveNonzeroInteger {
@@ -83,11 +83,14 @@ impl PositiveNonzeroInteger {
#[test]
fn test_positive_nonzero_integer_creation() {
assert!(PositiveNonzeroInteger::new(10).is_ok());
- assert_eq!(Err(CreationError::Negative), PositiveNonzeroInteger::new(-10));
+ assert_eq!(
+ Err(CreationError::Negative),
+ PositiveNonzeroInteger::new(-10)
+ );
assert_eq!(Err(CreationError::Zero), PositiveNonzeroInteger::new(0));
}
-#[derive(PartialEq,Debug)]
+#[derive(PartialEq, Debug)]
enum CreationError {
Negative,
Zero,
@@ -108,6 +111,36 @@ impl error::Error for CreationError {
}
}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
// First hint: To figure out what type should go where the ??? is, take a look
// at the test helper function `test_with_str`, since it returns whatever
// `read_and_validate` returns and`test_with_str` has its signature fully
diff --git a/exercises/error_handling/option1.rs b/exercises/error_handling/option1.rs
index 9cf0bc9..13fc720 100644
--- a/exercises/error_handling/option1.rs
+++ b/exercises/error_handling/option1.rs
@@ -11,7 +11,10 @@ fn main() {
println!("The last item in the list is {:?}", last);
let second_to_last = list.pop().unwrap();
- println!("The second-to-last item in the list is {:?}", second_to_last);
+ println!(
+ "The second-to-last item in the list is {:?}",
+ second_to_last
+ );
}
diff --git a/exercises/error_handling/result1.rs b/exercises/error_handling/result1.rs
index 851ab45..f9596e2 100644
--- a/exercises/error_handling/result1.rs
+++ b/exercises/error_handling/result1.rs
@@ -1,10 +1,10 @@
// result1.rs
// Make this test pass! Scroll down for hints :)
-#[derive(PartialEq,Debug)]
+#[derive(PartialEq, Debug)]
struct PositiveNonzeroInteger(u64);
-#[derive(PartialEq,Debug)]
+#[derive(PartialEq, Debug)]
enum CreationError {
Negative,
Zero,
@@ -19,7 +19,10 @@ impl PositiveNonzeroInteger {
#[test]
fn test_creation() {
assert!(PositiveNonzeroInteger::new(10).is_ok());
- assert_eq!(Err(CreationError::Negative), PositiveNonzeroInteger::new(-10));
+ assert_eq!(
+ Err(CreationError::Negative),
+ PositiveNonzeroInteger::new(-10)
+ );
assert_eq!(Err(CreationError::Zero), PositiveNonzeroInteger::new(0));
}
diff --git a/exercises/standard_library_types/iterator3.rs b/exercises/standard_library_types/iterator3.rs
index 1d2e135..083c0af 100644
--- a/exercises/standard_library_types/iterator3.rs
+++ b/exercises/standard_library_types/iterator3.rs
@@ -114,7 +114,7 @@ mod tests {
-// Minor hint: In each of the two cases in the match in main, you can create x with either
+// Minor hint: In each of the two cases in the match in main, you can create x with either
// a 'turbofish' or by hinting the type of x to the compiler. You may try both.
@@ -143,5 +143,5 @@ mod tests {
-// Major hint: Have a look at the Iter trait and at the explanation of its collect function.
+// Major hint: Have a look at the Iter trait and at the explanation of its collect function.
// Especially the part about Result is interesting.
diff --git a/src/exercise.rs b/src/exercise.rs
index e0c6ce7c8..6f526e7 100644
--- a/src/exercise.rs
+++ b/src/exercise.rs
@@ -1,7 +1,7 @@
use serde::Deserialize;
use std::fmt::{self, Display, Formatter};
-use std::fs::{remove_file};
-use std::path::{PathBuf};
+use std::fs::remove_file;
+use std::path::PathBuf;
use std::process::{self, Command, Output};
const RUSTC_COLOR_ARGS: &[&str] = &["--color", "always"];
@@ -63,8 +63,8 @@ impl Display for Exercise {
#[cfg(test)]
mod test {
use super::*;
- use std::path::Path;
use std::fs::File;
+ use std::path::Path;
#[test]
fn test_clean() {
diff --git a/src/run.rs b/src/run.rs
index e108e78..1484351 100644
--- a/src/run.rs
+++ b/src/run.rs
@@ -1,4 +1,4 @@
-use crate::exercise::{Mode, Exercise};
+use crate::exercise::{Exercise, Mode};
use crate::verify::test;
use console::{style, Emoji};
use indicatif::ProgressBar;
diff --git a/src/verify.rs b/src/verify.rs
index c4451b2..4778180 100644
--- a/src/verify.rs
+++ b/src/verify.rs
@@ -2,7 +2,7 @@ use crate::exercise::{Exercise, Mode};
use console::{style, Emoji};
use indicatif::ProgressBar;
-pub fn verify<'a>(start_at: impl IntoIterator<Item=&'a Exercise>) -> Result<(), ()> {
+pub fn verify<'a>(start_at: impl IntoIterator<Item = &'a Exercise>) -> Result<(), ()> {
for exercise in start_at {
match exercise.mode {
Mode::Test => test(&exercise)?,