From eb13c2b6afd4ae22370698561478e27c8633a918 Mon Sep 17 00:00:00 2001 From: Russell Cousineau Date: Thu, 6 Jun 2019 19:52:42 -0700 Subject: [PATCH] chore: Clean up some formatting in exercises --- exercises/functions/functions5.rs | 2 +- exercises/if/if1.rs | 2 +- exercises/modules/modules2.rs | 10 ++++++---- exercises/move_semantics/move_semantics1.rs | 1 - exercises/move_semantics/move_semantics2.rs | 1 - exercises/move_semantics/move_semantics3.rs | 1 - exercises/move_semantics/move_semantics4.rs | 1 - exercises/primitive_types/primitive_types6.rs | 4 ++-- exercises/standard_library_types/arc1.rs | 3 +-- exercises/standard_library_types/iterators3.rs | 5 ++--- exercises/test3.rs | 8 ++++++-- 11 files changed, 19 insertions(+), 19 deletions(-) diff --git a/exercises/functions/functions5.rs b/exercises/functions/functions5.rs index d3ff002..d9227c9 100644 --- a/exercises/functions/functions5.rs +++ b/exercises/functions/functions5.rs @@ -40,7 +40,7 @@ fn square(num: i32) -> i32 { // This is a really common error that can be fixed by removing one character. // It happens because Rust distinguishes between expressions and statements: expressions return -// a value based on its operand, and statements simply return a () type which behaves just like `void` in C/C++ language. +// a value based on its operand, and statements simply return a () type which behaves just like `void` in C/C++ language. // We want to return a value of `i32` type from the `square` function, but it is returning a `()` type... // They are not the same. There are two solutions: // 1. Add a `return` ahead of `num * num;` diff --git a/exercises/if/if1.rs b/exercises/if/if1.rs index 6dd64c0..636e6ce 100644 --- a/exercises/if/if1.rs +++ b/exercises/if/if1.rs @@ -1,6 +1,6 @@ // if1.rs -pub fn bigger(a: i32, b:i32) -> i32 { +pub fn bigger(a: i32, b: i32) -> i32 { // Complete this function to return the bigger number! // Do not use: // - return diff --git a/exercises/modules/modules2.rs b/exercises/modules/modules2.rs index d5946e5..3cfa36d 100644 --- a/exercises/modules/modules2.rs +++ b/exercises/modules/modules2.rs @@ -1,7 +1,7 @@ // modules2.rs // Make me compile! Scroll down for hints :) -mod delicious_snacks { +mod delicious_snacks { use self::fruits::PEAR as fruit; use self::veggies::CUCUMBER as veggie; @@ -17,9 +17,11 @@ mod delicious_snacks { } fn main() { - println!("favorite snacks: {} and {}", - delicious_snacks::fruit, - delicious_snacks::veggie); + println!( + "favorite snacks: {} and {}", + delicious_snacks::fruit, + delicious_snacks::veggie + ); } diff --git a/exercises/move_semantics/move_semantics1.rs b/exercises/move_semantics/move_semantics1.rs index 37038ec..ab855fc 100644 --- a/exercises/move_semantics/move_semantics1.rs +++ b/exercises/move_semantics/move_semantics1.rs @@ -11,7 +11,6 @@ fn main() { vec1.push(88); println!("{} has length {} content `{:?}`", "vec1", vec1.len(), vec1); - } fn fill_vec(vec: Vec) -> Vec { diff --git a/exercises/move_semantics/move_semantics2.rs b/exercises/move_semantics/move_semantics2.rs index b50e349..f85b3ed 100644 --- a/exercises/move_semantics/move_semantics2.rs +++ b/exercises/move_semantics/move_semantics2.rs @@ -12,7 +12,6 @@ fn main() { vec1.push(88); println!("{} has length {} content `{:?}`", "vec1", vec1.len(), vec1); - } fn fill_vec(vec: Vec) -> Vec { diff --git a/exercises/move_semantics/move_semantics3.rs b/exercises/move_semantics/move_semantics3.rs index 8e7b0ad..8b91896 100644 --- a/exercises/move_semantics/move_semantics3.rs +++ b/exercises/move_semantics/move_semantics3.rs @@ -13,7 +13,6 @@ fn main() { vec1.push(88); println!("{} has length {} content `{:?}`", "vec1", vec1.len(), vec1); - } fn fill_vec(vec: Vec) -> Vec { diff --git a/exercises/move_semantics/move_semantics4.rs b/exercises/move_semantics/move_semantics4.rs index d47e009..90930f0 100644 --- a/exercises/move_semantics/move_semantics4.rs +++ b/exercises/move_semantics/move_semantics4.rs @@ -13,7 +13,6 @@ fn main() { vec1.push(88); println!("{} has length {} content `{:?}`", "vec1", vec1.len(), vec1); - } // `fill_vec()` no longer take `vec: Vec` as argument diff --git a/exercises/primitive_types/primitive_types6.rs b/exercises/primitive_types/primitive_types6.rs index 634e56b..fcf24db 100644 --- a/exercises/primitive_types/primitive_types6.rs +++ b/exercises/primitive_types/primitive_types6.rs @@ -38,8 +38,8 @@ fn main() { -// While you could use a destructuring `let` for the tuple here, try -// indexing into it instead, as explained in the last example of the +// While you could use a destructuring `let` for the tuple here, try +// indexing into it instead, as explained in the last example of the // Data Types -> The Tuple Type section of the book: // https://doc.rust-lang.org/stable/book/ch03-02-data-types.html#the-tuple-type // Now you have another tool in your toolbox! diff --git a/exercises/standard_library_types/arc1.rs b/exercises/standard_library_types/arc1.rs index c744a10..d610e5f 100644 --- a/exercises/standard_library_types/arc1.rs +++ b/exercises/standard_library_types/arc1.rs @@ -13,8 +13,7 @@ fn main() { let mut joinhandles = Vec::new(); for offset in 0..8 { - joinhandles.push( - thread::spawn(move || { + joinhandles.push(thread::spawn(move || { let mut i = offset; let mut sum = 0; while i < child_numbers.len() { diff --git a/exercises/standard_library_types/iterators3.rs b/exercises/standard_library_types/iterators3.rs index 9019a94..c012795 100644 --- a/exercises/standard_library_types/iterators3.rs +++ b/exercises/standard_library_types/iterators3.rs @@ -23,8 +23,7 @@ pub struct NotDivisibleError { // This function should calculate `a` divided by `b` if `a` is // evenly divisible by b. // Otherwise, it should return a suitable error. -pub fn divide(a: i32, b: i32) -> Result { -} +pub fn divide(a: i32, b: i32) -> Result {} #[cfg(test)] mod tests { @@ -40,7 +39,7 @@ mod tests { fn test_not_divisible() { assert_eq!( divide(81, 6), - Err(DivisionError::NotDivisible(NotDivisibleError{ + Err(DivisionError::NotDivisible(NotDivisibleError { dividend: 81, divisor: 6 })) diff --git a/exercises/test3.rs b/exercises/test3.rs index e94b069..c8a5578 100644 --- a/exercises/test3.rs +++ b/exercises/test3.rs @@ -7,8 +7,12 @@ // you think each value is. That is, add either `string_slice` or `string` // before the parentheses on each line. If you're right, it will compile! -fn string_slice(arg: &str) { println!("{}", arg); } -fn string(arg: String) { println!("{}", arg); } +fn string_slice(arg: &str) { + println!("{}", arg); +} +fn string(arg: String) { + println!("{}", arg); +} fn main() { ("blue");