From 0fcfd332dd5057a590371c28ed3e6b267f788b76 Mon Sep 17 00:00:00 2001 From: Hunter Kvalevog Date: Sun, 27 Sep 2026 11:08:08 -0500 Subject: rustlings: complete 11 --- rustlings/exercises/quizzes/quiz2.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'rustlings/exercises/quizzes') diff --git a/rustlings/exercises/quizzes/quiz2.rs b/rustlings/exercises/quizzes/quiz2.rs index 2cddba9..fd32810 100644 --- a/rustlings/exercises/quizzes/quiz2.rs +++ b/rustlings/exercises/quizzes/quiz2.rs @@ -28,6 +28,23 @@ mod my_module { // TODO: Complete the function as described above. // pub fn transformer(input: ???) -> ??? { ??? } + pub fn transformer(input: Vec<(String, Command)>) -> Vec { + let mut out = Vec::new(); + for inp in input { + out.push(match inp.1 { + Command::Uppercase => inp.0.to_uppercase(), + Command::Trim => String::from(inp.0.trim()), + Command::Append(n) => { + let mut r = inp.0; + for _ in 0..n { + r += "bar"; + } + r + } + }); + } + out + } } fn main() { @@ -39,6 +56,7 @@ mod tests { // TODO: What do we need to import to have `transformer` in scope? // use ???; use super::Command; + use super::my_module::transformer; #[test] fn it_works() { -- cgit v1.2.3