This commit is contained in:
enforcer007 2022-11-13 13:31:46 +05:30
parent d475cef554
commit 17398a16e2

View File

@ -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,
@ -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![];
for (string, command) in input.iter() {
let mut output: Vec<String> = vec![];
for (string, command) in input.into_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().into()),
Command::Append(x) => output.push(string + &"bar".repeat(x)),
}
}
output
}
@ -43,7 +46,7 @@ mod my_module {
#[cfg(test)]
mod tests {
// TODO: What do we have to import to have `transformer` in scope?
use ???;
use super::my_module::transformer;
use super::Command;
#[test]