Complete quiz2

This commit is contained in:
Rock070 2024-05-05 17:24:14 +08:00
parent fdf1d54080
commit 7b6ebb8654

View File

@ -32,10 +32,15 @@ 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() {
match command {
Command::Uppercase => output.push(string.to_uppercase()),
Command::Trim => output.push(string.trim().to_owned()),
Command::Append(n) => output.push(string.to_owned() + &("bar".repeat(*n))),
}
// TODO: Complete the function body. You can do it!
}
output
@ -45,7 +50,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]