Quiz 2
This commit is contained in:
parent
757596b997
commit
4f57728dd9
|
@ -18,8 +18,6 @@
|
||||||
// - The output element is going to be a Vector of strings.
|
// - The output element is going to be a Vector of strings.
|
||||||
// No hints this time!
|
// No hints this time!
|
||||||
|
|
||||||
// I AM NOT DONE
|
|
||||||
|
|
||||||
pub enum Command {
|
pub enum Command {
|
||||||
Uppercase,
|
Uppercase,
|
||||||
Trim,
|
Trim,
|
||||||
|
@ -29,12 +27,14 @@ pub enum Command {
|
||||||
mod my_module {
|
mod my_module {
|
||||||
use super::Command;
|
use super::Command;
|
||||||
|
|
||||||
// TODO: Complete the function signature!
|
pub fn transformer(input: Vec<(String, Command)>) -> Vec<String> {
|
||||||
pub fn transformer(input: ???) -> ??? {
|
let mut output: Vec<String> = vec![];
|
||||||
// TODO: Complete the output declaration!
|
|
||||||
let mut output: ??? = vec![];
|
|
||||||
for (string, command) in input.iter() {
|
for (string, command) in input.iter() {
|
||||||
// TODO: Complete the function body. You can do it!
|
output.push(match command {
|
||||||
|
Command::Uppercase => string.to_uppercase(),
|
||||||
|
Command::Trim => string.trim().to_string(),
|
||||||
|
Command::Append(times) => format!("{}{}", string, "bar".repeat(*times)),
|
||||||
|
})
|
||||||
}
|
}
|
||||||
output
|
output
|
||||||
}
|
}
|
||||||
|
@ -42,8 +42,7 @@ mod my_module {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
// TODO: What do we need to import to have `transformer` in scope?
|
use super::my_module::transformer;
|
||||||
use ???;
|
|
||||||
use super::Command;
|
use super::Command;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
Loading…
Reference in New Issue