This commit is contained in:
2024-04-10 14:36:38 -04:00
parent be78a78343
commit c682aa9c6c
16 changed files with 72 additions and 57 deletions

View File

@@ -20,8 +20,6 @@
//
// No hints this time!
// I AM NOT DONE
pub enum Command {
Uppercase,
Trim,
@@ -32,11 +30,25 @@ 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!
match command {
Command::Uppercase => {
output.push(string.to_uppercase())
},
Command::Trim => {
output.push(string.trim().to_string())
},
Command::Append(s) => {
let mut new_string: String = string.into();
for i in 0..(*s as u8) {
new_string.push_str("bar");
}
output.push(new_string);
}
}
}
output
}
@@ -45,7 +57,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]