feat: completed solutions
This commit is contained in:
@@ -27,7 +27,21 @@ mod my_module {
|
||||
use super::Command;
|
||||
|
||||
// TODO: Complete the function as described above.
|
||||
// pub fn transformer(input: ???) -> ??? { ??? }
|
||||
pub fn transformer(input: Vec<(String, Command)>) -> Vec<String> {
|
||||
let mut output: Vec<String> = Vec::new();
|
||||
|
||||
for (string, command) in input {
|
||||
match command {
|
||||
Command::Uppercase => output.push(string.to_uppercase()),
|
||||
Command::Trim => output.push(string.trim().into()),
|
||||
Command::Append(number_of_times_bar_will_be_added) => {
|
||||
output.push(string + &"bar".repeat(number_of_times_bar_will_be_added))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
output
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
@@ -37,8 +51,8 @@ fn main() {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
// TODO: What do we need to import to have `transformer` in scope?
|
||||
// use ???;
|
||||
use super::Command;
|
||||
use super::my_module::transformer;
|
||||
|
||||
#[test]
|
||||
fn it_works() {
|
||||
|
||||
Reference in New Issue
Block a user