From a7ac5664672ff869dd3a4fc97db33ee798052362 Mon Sep 17 00:00:00 2001 From: "David E. Perez Negron R." Date: Sat, 11 Nov 2023 00:58:34 -0600 Subject: [PATCH] quiz2 done --- exercises/quiz2.rs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/exercises/quiz2.rs b/exercises/quiz2.rs index 29925ca..f25d20d 100644 --- a/exercises/quiz2.rs +++ b/exercises/quiz2.rs @@ -20,7 +20,6 @@ // // No hints this time! -// I AM NOT DONE pub enum Command { Uppercase, @@ -32,11 +31,22 @@ mod my_module { 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(i) =>{ + let mut string = string.to_string(); + for foo in 0..*i { + string += "bar"; + } + output.push(string) + }, + } } output } @@ -45,7 +55,7 @@ mod my_module { #[cfg(test)] mod tests { // TODO: What do we need to import to have `transformer` in scope? - use ???; + use crate::my_module::transformer; use super::Command; #[test]