feat(section): hashmap + section complete w/ quiz2

This commit is contained in:
2026-08-04 20:36:07 +02:00
parent 2844976587
commit 8b15f8d511
2 changed files with 25 additions and 0 deletions
+20
View File
@@ -28,6 +28,25 @@ 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 output = Vec::new();
for (s, cmd) in input {
let transformed = match cmd {
Command::Uppercase => s.to_uppercase(),
Command::Trim => s.trim().to_owned(),
Command::Append(n) => {
let mut out = s;
for _ in 0..n {
out.push_str("bar");
}
out
}
};
output.push(transformed)
}
output
}
}
fn main() {
@@ -39,6 +58,7 @@ mod tests {
// TODO: What do we need to import to have `transformer` in scope?
// use ???;
use super::Command;
use crate::my_module::transformer;
#[test]
fn it_works() {