cargo fmt
This commit is contained in:
@@ -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::<Vec<String>>();
|
||||
let transformed = words
|
||||
.into_iter()
|
||||
.filter(|w| !w.contains("h"))
|
||||
.map(|w| w.to_uppercase())
|
||||
.collect::<Vec<String>>();
|
||||
println!("Transformed: {:?}", transformed);
|
||||
|
||||
// Challenge:
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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<Vec<String>>`. The vector of Strings will
|
||||
// represent successful outcomes of various dolphin tricks.
|
||||
|
||||
use anyhow::Result;
|
||||
|
||||
fn play_time(dolphin: &Dolphin) -> Result<Vec<String>> {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use testing::{sploosh, splish};
|
||||
use testing::{splish, sploosh};
|
||||
|
||||
#[test]
|
||||
pub fn test_sploosh_splish() {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user