File tree Expand file tree Collapse file tree 1 file changed +17
-5
lines changed
Expand file tree Collapse file tree 1 file changed +17
-5
lines changed Original file line number Diff line number Diff line change @@ -32,20 +32,32 @@ mod my_module {
3232 use super :: Command ;
3333
3434 // TODO: Complete the function signature!
35- pub fn transformer ( input : ??? ) -> ??? {
35+ pub fn transformer ( input : Vec < ( String , Command ) > ) -> Vec < String > {
3636 // TODO: Complete the output declaration!
37- let mut output: ??? = vec ! [ ] ;
37+ let mut output: Vec < String > = vec ! [ ] ;
3838 for ( string, command) in input. iter ( ) {
3939 // TODO: Complete the function body. You can do it!
40- }
41- output
40+ let result = match command {
41+ Command :: Uppercase => string. to_uppercase ( ) ,
42+ Command :: Trim => string. trim ( ) . to_string ( ) ,
43+ Command :: Append ( n) => {
44+ let mut result = string. clone ( ) ;
45+ for _ in 0 ..* n {
46+ result. push_str ( "bar" ) ;
47+ }
48+ result
49+ }
50+ } ;
51+ output. push ( result)
4252 }
53+ output
54+ }
4355}
4456
4557#[ cfg( test) ]
4658mod tests {
4759 // TODO: What do we need to import to have `transformer` in scope?
48- use ??? ;
60+ use super :: my_module :: transformer ;
4961 use super :: Command ;
5062
5163 #[ test]
You can’t perform that action at this time.
0 commit comments