summaryrefslogtreecommitdiff
path: root/rustlings/exercises/quizzes/quiz2.rs
diff options
context:
space:
mode:
authorHunter Kvalevog <hunter@kvog.sh>2026-09-27 11:08:08 -0500
committerHunter Kvalevog <hunter@kvog.sh>2026-09-27 11:08:08 -0500
commit0fcfd332dd5057a590371c28ed3e6b267f788b76 (patch)
treee7fbb66a21de3e7613d81eb8a592d2709afec81b /rustlings/exercises/quizzes/quiz2.rs
parent4abf853ebed9608583a39b13ab3cd3f14ecd1f4b (diff)
rustlings: complete 11
Diffstat (limited to 'rustlings/exercises/quizzes/quiz2.rs')
-rw-r--r--rustlings/exercises/quizzes/quiz2.rs18
1 files changed, 18 insertions, 0 deletions
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<String> {
+ 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() {