File tree 1 file changed +16
-4
lines changed
1 file changed +16
-4
lines changed Original file line number Diff line number Diff line change 19
19
// - The output element is going to be a Vector of strings.
20
20
//
21
21
// No hints this time!
22
-
23
22
// I AM NOT DONE
24
23
25
24
pub enum Command {
@@ -32,11 +31,24 @@ mod my_module {
32
31
use super :: Command ;
33
32
34
33
// TODO: Complete the function signature!
35
- pub fn transformer ( input : ??? ) -> ??? {
34
+ pub fn transformer ( input : Vec < ( String , Command ) > ) -> Vec < String > {
36
35
// TODO: Complete the output declaration!
37
- let mut output: ??? = vec ! [ ] ;
36
+ let mut output: Vec < String > = vec ! [ ] ;
38
37
for ( string, command) in input. iter ( ) {
39
38
// TODO: Complete the function body. You can do it!
39
+ match command {
40
+ Command :: Uppercase => output. push ( string. to_uppercase ( ) ) ,
41
+ Command :: Trim => output. push ( string. trim ( ) . to_string ( ) ) ,
42
+ Command :: Append ( num) => {
43
+ let mut append = String :: new ( ) ;
44
+ let mut n: usize = 0 ;
45
+ while n < * num {
46
+ append. push_str ( "bar" ) ;
47
+ n += 1 ;
48
+ }
49
+ output. push ( string . to_owned ( ) + & append) ;
50
+ } ,
51
+ }
40
52
}
41
53
output
42
54
}
@@ -45,7 +57,7 @@ mod my_module {
45
57
#[ cfg( test) ]
46
58
mod tests {
47
59
// TODO: What do we need to import to have `transformer` in scope?
48
- use ??? ;
60
+ use super :: my_module :: transformer ;
49
61
use super :: Command ;
50
62
51
63
#[ test]
You can’t perform that action at this time.
0 commit comments