🦀 Quiz Solved

This commit is contained in:
asif256000 2023-01-12 20:17:51 -05:00
parent 52d47e1d2f
commit 179bc4ad68

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,
@ -27,14 +25,21 @@ pub enum Command {
}
mod my_module {
// use std::marker::Tuple;
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(x) => output.push(string.to_owned() + &"bar".repeat(*x)),
}
}
output
}
@ -43,8 +48,8 @@ mod my_module {
#[cfg(test)]
mod tests {
// TODO: What do we have to import to have `transformer` in scope?
use ???;
use super::Command;
use my_module::transformer;
#[test]
fn it_works() {