This commit is contained in:
contre95 2023-03-22 17:12:21 +01:00
parent 48350051bc
commit 0b26dbae59
2 changed files with 14 additions and 11 deletions

View File

@ -14,8 +14,6 @@
// Execute `rustlings hint hashmaps3` or use the `hint` watch subcommand for a hint. // Execute `rustlings hint hashmaps3` or use the `hint` watch subcommand for a hint.
// I AM NOT DONE
use std::collections::HashMap; use std::collections::HashMap;
struct Team { struct Team {

View File

@ -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,
@ -28,13 +26,20 @@ pub enum Command {
mod my_module { mod my_module {
use super::Command; use super::Command;
pub fn transformer(input: Vec<(String, Command)>) -> Vec<String> {
// TODO: Complete the function signature! let mut output: Vec<String> = vec![];
pub fn transformer(input: ???) -> ??? {
// 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().into(),
Command::Append(times) => {
let mut string = string.clone();
for _ in 0..*times {
string += "bar";
}
string
},
})
} }
output output
} }
@ -43,7 +48,7 @@ mod my_module {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
// TODO: What do we need to import to have `transformer` in scope? // TODO: What do we need to import to have `transformer` in scope?
use ???; use my_module::transformer;
use super::Command; use super::Command;
#[test] #[test]