diff --git a/exercises/quiz2.rs b/exercises/quiz2.rs index 606d3c70..a4141f33 100644 --- a/exercises/quiz2.rs +++ b/exercises/quiz2.rs @@ -18,8 +18,6 @@ // - The output element is going to be a Vector of strings. // No hints this time! -// I AM NOT DONE - pub enum Command { Uppercase, Trim, @@ -27,14 +25,21 @@ pub enum Command { } mod my_module { + // use std::marker::Tuple; + use super::Command; // TODO: Complete the function signature! - pub fn transformer(input: ???) -> ??? { + pub fn transformer(input: Vec<(String, Command)>) -> 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! + match command { + Command::Uppercase => output.push(string.to_uppercase()), + Command::Trim => output.push(string.trim().to_string()), + Command::Append(x) => output.push(string.to_owned() + &"bar".repeat(*x)), + } } output } @@ -43,8 +48,8 @@ mod my_module { #[cfg(test)] mod tests { // TODO: What do we have to import to have `transformer` in scope? - use ???; use super::Command; + use my_module::transformer; #[test] fn it_works() {