diff --git a/exercise/closures_iterators/src/main.rs b/exercise/closures_iterators/src/main.rs index e0d8355..b2cc010 100644 --- a/exercise/closures_iterators/src/main.rs +++ b/exercise/closures_iterators/src/main.rs @@ -41,7 +41,11 @@ fn main() { // Hint: .to_uppercase() is a method on `str` which returns a String let words = vec!["autobot", "beach", "car", "decepticon", "energon", "frothy"]; - let transformed = words.into_iter().filter(|w| !w.contains("h")).map(|w| w.to_uppercase()).collect::>(); + let transformed = words + .into_iter() + .filter(|w| !w.contains("h")) + .map(|w| w.to_uppercase()) + .collect::>(); println!("Transformed: {:?}", transformed); // Challenge: diff --git a/exercise/docs/src/lib.rs b/exercise/docs/src/lib.rs index b79454a..8486e37 100644 --- a/exercise/docs/src/lib.rs +++ b/exercise/docs/src/lib.rs @@ -23,9 +23,9 @@ // - Document the "orangeness" field, explaining that it is a number from 8 to 27 /// Big orange thing -/// +/// /// # Recipes -/// +/// /// Recipes will be coming soon. pub struct Pumpkin { /// `roundness` is a percentage that describes how round the pumpkin is. diff --git a/exercise/errors/src/lib.rs b/exercise/errors/src/lib.rs index 50ef2bf..f681531 100644 --- a/exercise/errors/src/lib.rs +++ b/exercise/errors/src/lib.rs @@ -24,7 +24,7 @@ pub enum DolphinError { #[error("The dolphin is too young")] TooYoung, #[error("The dolphin's name is too long and annoying to say")] - LongName + LongName, } pub struct Dolphin { diff --git a/exercise/errors/src/main.rs b/exercise/errors/src/main.rs index 4399d05..275c88f 100644 --- a/exercise/errors/src/main.rs +++ b/exercise/errors/src/main.rs @@ -3,14 +3,12 @@ use aquarium::Dolphin; // Silence some warnings so they don't distract from the exercise. #[allow(clippy::vec_init_then_push)] - // (You already did #1 in lib.rs, right?) // // 2a. Uncomment and finish the play_time function below // - Bring anyhow::Result into scope with a `use` statement // - Have the play_time function return a `Result>`. The vector of Strings will // represent successful outcomes of various dolphin tricks. - use anyhow::Result; fn play_time(dolphin: &Dolphin) -> Result> { @@ -18,10 +16,10 @@ fn play_time(dolphin: &Dolphin) -> Result> { // 2b. Call the .say_your_name() method on `dolphin`, use `?` to unwrap the value, and push // the value onto the `responses` vector. // - let response = dolphin.say_your_name()?; // this can be done with an intermediate variable... + let response = dolphin.say_your_name()?; // this can be done with an intermediate variable... responses.push(response); // ...or all on one line. Either way is fine! - // - // 2c. Do the same thing as #2b for the .flip() method + // + // 2c. Do the same thing as #2b for the .flip() method responses.push(dolphin.flip()?); // // 2d. Do the same thing as #2b for the .shake_hands() method @@ -56,7 +54,7 @@ fn main() -> Result<()> { for dolphin in &dolphins { // Challenge: Change main() so that it returns a Result, and instead of handling the error // that play_time returns, use the try (?) operator to only handle the success condition. - // + // // If done correctly, the output of the program will become much shorter. Since play_time // returns an Err variant the first time it is called, the try operator will return it from // main(), which will end the program at the first error. anyhow's Result will take care of diff --git a/exercise/logging/src/lib.rs b/exercise/logging/src/lib.rs index 2364739..4f50ff2 100644 --- a/exercise/logging/src/lib.rs +++ b/exercise/logging/src/lib.rs @@ -6,7 +6,7 @@ // // Hint: You need to update Cargo.toml to add the `log` dependency, first. -use log::{error, warn, info, debug, trace}; +use log::{debug, error, info, trace, warn}; #[derive(Debug)] pub struct Frog { diff --git a/exercise/testing/benches/somename.rs b/exercise/testing/benches/somename.rs index 936fefc..0891b88 100644 --- a/exercise/testing/benches/somename.rs +++ b/exercise/testing/benches/somename.rs @@ -2,7 +2,9 @@ use criterion::{black_box, criterion_group, criterion_main, Criterion}; use testing::sploosh; pub fn sploosh_benchmark(c: &mut Criterion) { - c.bench_function("sploosh", |b| b.iter(|| sploosh(black_box(8), black_box(9), black_box(10)))); + c.bench_function("sploosh", |b| { + b.iter(|| sploosh(black_box(8), black_box(9), black_box(10))) + }); } criterion_group!(benches, sploosh_benchmark); diff --git a/exercise/testing/tests/more_tests.rs b/exercise/testing/tests/more_tests.rs index d6fa1ff..8631e41 100644 --- a/exercise/testing/tests/more_tests.rs +++ b/exercise/testing/tests/more_tests.rs @@ -1,4 +1,4 @@ -use testing::{sploosh, splish}; +use testing::{splish, sploosh}; #[test] pub fn test_sploosh_splish() { diff --git a/exercise/threads_channels/src/main.rs b/exercise/threads_channels/src/main.rs index fac7c3e..aefd98d 100644 --- a/exercise/threads_channels/src/main.rs +++ b/exercise/threads_channels/src/main.rs @@ -113,13 +113,7 @@ fn main() { } }); - for number in vec![ - 1, - 2, - 3, - 4, - 5, - ] { + for number in vec![1, 2, 3, 4, 5] { println!("NUMBER: {}", number); let _ = tx.send(number); } diff --git a/exercise/traits/src/main.rs b/exercise/traits/src/main.rs index e365b0c..32da16d 100644 --- a/exercise/traits/src/main.rs +++ b/exercise/traits/src/main.rs @@ -17,7 +17,7 @@ impl Default for Party { Self { at_restaurant: true, num_people: 8, - cake: Cake::Chocolate + cake: Cake::Chocolate, } } } @@ -110,7 +110,10 @@ fn main() { // consuming it. Change the code above to pass in a &party. Then uncomment and run the code // below. After all, you want to smell your cake and eat it, too! - println!("Yum! I'm eating this cake: {:?}. Oops, I dropped it on the floor.", party.cake); + println!( + "Yum! I'm eating this cake: {:?}. Oops, I dropped it on the floor.", + party.cake + ); } pub fn admire_cake(cake: Cake) {