From 7c2e0d575d5629e30daf9258fad190671e3b3b62 Mon Sep 17 00:00:00 2001 From: jojimanos Date: Sun, 11 Sep 2022 12:42:04 +0300 Subject: [PATCH] quiz1&2 --- exercises/quiz1.rs | 10 +++++++--- exercises/quiz2.rs | 6 +++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/exercises/quiz1.rs b/exercises/quiz1.rs index dbb5cdc9..66c26cc3 100644 --- a/exercises/quiz1.rs +++ b/exercises/quiz1.rs @@ -10,10 +10,14 @@ // Write a function that calculates the price of an order of apples given // the quantity bought. No hints this time! -// I AM NOT DONE - // Put your function here! -// fn calculate_price_of_apples { + fn calculate_price_of_apples(price: u32)-> u32 { + if price > 40{ + return price; + } else { + price*2 + } + } // Don't modify this function! #[test] diff --git a/exercises/quiz2.rs b/exercises/quiz2.rs index d8fa954a..97be62ea 100644 --- a/exercises/quiz2.rs +++ b/exercises/quiz2.rs @@ -30,9 +30,9 @@ mod my_module { use super::Command; // TODO: Complete the function signature! - pub fn transformer(input: ???) -> ??? { + pub fn transformer(input: Vec = [Trim, "Hello"]) -> Vec { // TODO: Complete the output declaration! - let mut output: ??? = vec![]; + let mut output: Vec = vec![]; for (string, command) in input.iter() { // TODO: Complete the function body. You can do it! } @@ -43,7 +43,7 @@ mod my_module { #[cfg(test)] mod tests { // TODO: What do we have to import to have `transformer` in scope? - use ???; + use vec![enum, ""]; use super::Command; #[test]