quiz2 done

This commit is contained in:
David E. Perez Negron R. 2023-11-11 00:58:34 -06:00
parent 4af39ccfde
commit a7ac566467
1 changed files with 14 additions and 4 deletions

View File

@ -20,7 +20,6 @@
// //
// No hints this time! // No hints this time!
// I AM NOT DONE
pub enum Command { pub enum Command {
Uppercase, Uppercase,
@ -32,11 +31,22 @@ mod my_module {
use super::Command; use super::Command;
// TODO: Complete the function signature! // TODO: Complete the function signature!
pub fn transformer(input: ???) -> ??? { pub fn transformer(input: Vec<(String, Command)>) -> Vec<String> {
// TODO: Complete the output declaration! // TODO: Complete the output declaration!
let mut output: ??? = vec![]; let mut output: Vec<String> = vec![];
for (string, command) in input.iter() { for (string, command) in input.iter() {
// TODO: Complete the function body. You can do it! // 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(i) =>{
let mut string = string.to_string();
for foo in 0..*i {
string += "bar";
}
output.push(string)
},
}
} }
output output
} }
@ -45,7 +55,7 @@ mod my_module {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
// TODO: What do we need to import to have `transformer` in scope? // TODO: What do we need to import to have `transformer` in scope?
use ???; use crate::my_module::transformer;
use super::Command; use super::Command;
#[test] #[test]