Skip to content

Commit

Permalink
quiz 2
Browse files Browse the repository at this point in the history
  • Loading branch information
afresquet committed Apr 19, 2023
1 parent f6fd192 commit 7ba4342
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions exercises/quiz2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
// - The output element is going to be a Vector of strings.
// No hints this time!

// I AM NOT DONE

pub enum Command {
Uppercase,
Trim,
Expand All @@ -30,11 +28,16 @@ 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![];
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(n) => output.push(string.to_owned() + &"bar".repeat(*n)),
}
}
output
}
Expand All @@ -43,7 +46,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 7ba4342

Please sign in to comment.