rustfmt the exercises

Signed-off-by: Eddy Petrisor <eddy.petrisor@gmail.com>
This commit is contained in:
Eddy Petrisor 2019-05-22 14:48:32 +03:00
parent a53b3f199f
commit 9aec4abc4d
4 changed files with 17 additions and 11 deletions

View File

@ -32,10 +32,7 @@ mod tests {
#[test] #[test]
fn item_quantity_is_a_valid_number() { fn item_quantity_is_a_valid_number() {
assert_eq!( assert_eq!(total_cost("34"), Ok(171));
total_cost("34"),
Ok(171)
);
} }
#[test] #[test]

View File

@ -65,7 +65,7 @@ fn test_ioerror() {
assert_eq!("uh-oh!", read_and_validate(&mut b).unwrap_err().to_string()); assert_eq!("uh-oh!", read_and_validate(&mut b).unwrap_err().to_string());
} }
#[derive(PartialEq,Debug)] #[derive(PartialEq, Debug)]
struct PositiveNonzeroInteger(u64); struct PositiveNonzeroInteger(u64);
impl PositiveNonzeroInteger { impl PositiveNonzeroInteger {
@ -83,11 +83,14 @@ impl PositiveNonzeroInteger {
#[test] #[test]
fn test_positive_nonzero_integer_creation() { fn test_positive_nonzero_integer_creation() {
assert!(PositiveNonzeroInteger::new(10).is_ok()); 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)); assert_eq!(Err(CreationError::Zero), PositiveNonzeroInteger::new(0));
} }
#[derive(PartialEq,Debug)] #[derive(PartialEq, Debug)]
enum CreationError { enum CreationError {
Negative, Negative,
Zero, Zero,

View File

@ -11,7 +11,10 @@ fn main() {
println!("The last item in the list is {:?}", last); println!("The last item in the list is {:?}", last);
let second_to_last = list.pop().unwrap(); 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
);
} }

View File

@ -1,10 +1,10 @@
// result1.rs // result1.rs
// Make this test pass! Scroll down for hints :) // Make this test pass! Scroll down for hints :)
#[derive(PartialEq,Debug)] #[derive(PartialEq, Debug)]
struct PositiveNonzeroInteger(u64); struct PositiveNonzeroInteger(u64);
#[derive(PartialEq,Debug)] #[derive(PartialEq, Debug)]
enum CreationError { enum CreationError {
Negative, Negative,
Zero, Zero,
@ -19,7 +19,10 @@ impl PositiveNonzeroInteger {
#[test] #[test]
fn test_creation() { fn test_creation() {
assert!(PositiveNonzeroInteger::new(10).is_ok()); 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)); assert_eq!(Err(CreationError::Zero), PositiveNonzeroInteger::new(0));
} }