Skip to content

Commit

Permalink
finish quiz2
Browse files Browse the repository at this point in the history
  • Loading branch information
cyz-ing committed Jan 19, 2025
1 parent 1d94e5d commit 1744408
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions exercises/quiz2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,24 @@ mod my_module {
use super::Command;

// TODO: Complete the function signature!
pub fn transformer(input: ???) -> ??? {
pub fn transformer(input: Vec<(String,Command)>) -> Vec<String> {
// TODO: Complete the output declaration!
let mut output: ??? = vec![];
let mut output: Vec<String> = vec![];
for (string, command) in input.iter() {
// TODO: Complete the function body. You can do it!
let processed_string = match command {
Command::Uppercase => string.to_uppercase(),
Command::Trim => string.trim().to_string(),
Command::Append(n) => {
let mut s = string.clone();
for _ in 0..*n {
s.push_str("bar");
}
s
}
};
output.push(processed_string);

}
output
}
Expand All @@ -45,7 +58,7 @@ mod my_module {
#[cfg(test)]
mod tests {
// TODO: What do we need to import to have `transformer` in scope?
use ???;
use super::my_module::transformer;
use super::Command;

#[test]
Expand Down

0 comments on commit 1744408

Please sign in to comment.