mirror of
https://github.com/rust-lang/rustlings.git
synced 2026-01-07 03:09:19 +00:00
commit
ff71b235a3
@ -20,8 +20,6 @@
|
|||||||
//
|
//
|
||||||
// No hints this time!
|
// No hints this time!
|
||||||
|
|
||||||
// I AM NOT DONE
|
|
||||||
|
|
||||||
pub enum Command {
|
pub enum Command {
|
||||||
Uppercase,
|
Uppercase,
|
||||||
Trim,
|
Trim,
|
||||||
@ -32,11 +30,16 @@ mod my_module {
|
|||||||
use super::Command;
|
use super::Command;
|
||||||
|
|
||||||
// TODO: Complete the function signature!
|
// TODO: Complete the function signature!
|
||||||
pub fn transformer(input: ???) -> ??? {
|
pub fn transformer(input: Vec<(String, Command)>) -> Vec<String> {
|
||||||
// TODO: Complete the output declaration!
|
// TODO: Complete the output declaration!
|
||||||
let mut output: ??? = vec![];
|
let mut output: Vec<String> = vec![];
|
||||||
for (string, command) in input.iter() {
|
for (string, command) in input.iter() {
|
||||||
// TODO: Complete the function body. You can do it!
|
// TODO: Complete the function body. You can do it!
|
||||||
|
match command {
|
||||||
|
Command::Uppercase => output.push(string.to_string().to_uppercase()),
|
||||||
|
Command::Trim => output.push(string.trim().to_string()),
|
||||||
|
Command::Append(usize) => output.push(string.to_owned() + &"bar".repeat(*usize)),
|
||||||
|
};
|
||||||
}
|
}
|
||||||
output
|
output
|
||||||
}
|
}
|
||||||
@ -45,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 super::my_module::*;
|
||||||
use super::Command;
|
use super::Command;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user