mirror of
https://github.com/rust-lang/rustlings.git
synced 2026-01-10 20:59:19 +00:00
✨ 🦀 Quiz Solved
This commit is contained in:
parent
52d47e1d2f
commit
179bc4ad68
@ -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,
|
||||||
@ -27,14 +25,21 @@ pub enum Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mod my_module {
|
mod my_module {
|
||||||
|
// use std::marker::Tuple;
|
||||||
|
|
||||||
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_uppercase()),
|
||||||
|
Command::Trim => output.push(string.trim().to_string()),
|
||||||
|
Command::Append(x) => output.push(string.to_owned() + &"bar".repeat(*x)),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
output
|
output
|
||||||
}
|
}
|
||||||
@ -43,8 +48,8 @@ mod my_module {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
// TODO: What do we have to import to have `transformer` in scope?
|
// TODO: What do we have to import to have `transformer` in scope?
|
||||||
use ???;
|
|
||||||
use super::Command;
|
use super::Command;
|
||||||
|
use my_module::transformer;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn it_works() {
|
fn it_works() {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user