File tree Expand file tree Collapse file tree 1 file changed +3
-8
lines changed Expand file tree Collapse file tree 1 file changed +3
-8
lines changed Original file line number Diff line number Diff line change @@ -24,17 +24,12 @@ mod my_module {
24
24
pub fn transformer ( input : Vec < ( String , Command ) > ) -> Vec < String > {
25
25
let mut output = Vec :: new ( ) ;
26
26
27
- for ( mut string, command) in input {
27
+ for ( string, command) in input {
28
28
// Create the new string.
29
29
let new_string = match command {
30
30
Command :: Uppercase => string. to_uppercase ( ) ,
31
31
Command :: Trim => string. trim ( ) . to_string ( ) ,
32
- Command :: Append ( n) => {
33
- for _ in 0 ..n {
34
- string += "bar" ;
35
- }
36
- string
37
- }
32
+ Command :: Append ( n) => string + & "bar" . repeat ( n) ,
38
33
} ;
39
34
40
35
// Push the new string to the output vector.
@@ -49,7 +44,7 @@ mod my_module {
49
44
pub fn transformer_iter ( input : Vec < ( String , Command ) > ) -> Vec < String > {
50
45
input
51
46
. into_iter ( )
52
- . map ( |( mut string, command) | match command {
47
+ . map ( |( string, command) | match command {
53
48
Command :: Uppercase => string. to_uppercase ( ) ,
54
49
Command :: Trim => string. trim ( ) . to_string ( ) ,
55
50
Command :: Append ( n) => string + & "bar" . repeat ( n) ,
You can’t perform that action at this time.
0 commit comments