mirror of
https://github.com/rust-lang/rustlings.git
synced 2026-01-02 16:59:18 +00:00
Complete quiz2
This commit is contained in:
parent
fdf1d54080
commit
7b6ebb8654
@ -32,10 +32,15 @@ mod my_module {
|
||||
use super::Command;
|
||||
|
||||
// TODO: Complete the function signature!
|
||||
pub fn transformer(input: ???) -> ??? {
|
||||
pub fn transformer(input: Vec<(String, Command)>) -> Vec<String> {
|
||||
// TODO: Complete the output declaration!
|
||||
let mut output: ??? = vec![];
|
||||
let mut output: Vec<String> = vec![];
|
||||
for (string, command) in input.iter() {
|
||||
match command {
|
||||
Command::Uppercase => output.push(string.to_uppercase()),
|
||||
Command::Trim => output.push(string.trim().to_owned()),
|
||||
Command::Append(n) => output.push(string.to_owned() + &("bar".repeat(*n))),
|
||||
}
|
||||
// TODO: Complete the function body. You can do it!
|
||||
}
|
||||
output
|
||||
@ -45,7 +50,7 @@ mod my_module {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
// TODO: What do we need to import to have `transformer` in scope?
|
||||
use ???;
|
||||
use super::my_module::transformer;
|
||||
use super::Command;
|
||||
|
||||
#[test]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user