File tree Expand file tree Collapse file tree 2 files changed +9
-9
lines changed
exercises/06_move_semantics
solutions/06_move_semantics Expand file tree Collapse file tree 2 files changed +9
-9
lines changed Original file line number Diff line number Diff line change @@ -8,11 +8,11 @@ mod tests {
88 // Don't add, change or remove any line.
99 #[ test]
1010 fn move_semantics4 ( ) {
11- let mut x = 100 ;
11+ let mut x = Vec :: new ( ) ;
1212 let y = & mut x;
1313 let z = & mut x;
14- * y += 100 ;
15- * z += 1000 ;
16- assert_eq ! ( x, 1200 ) ;
14+ y . push ( 42 ) ;
15+ z . push ( 13 ) ;
16+ assert_eq ! ( x, [ 42 , 13 ] ) ;
1717 }
1818}
Original file line number Diff line number Diff line change @@ -7,15 +7,15 @@ mod tests {
77 // TODO: Fix the compiler errors only by reordering the lines in the test.
88 // Don't add, change or remove any line.
99 #[ test]
10- fn move_semantics5 ( ) {
11- let mut x = 100 ;
10+ fn move_semantics4 ( ) {
11+ let mut x = Vec :: new ( ) ;
1212 let y = & mut x;
1313 // `y` used here.
14- * y += 100 ;
14+ y . push ( 42 ) ;
1515 // The mutable reference `y` is not used anymore,
1616 // therefore a new reference can be created.
1717 let z = & mut x;
18- * z += 1000 ;
19- assert_eq ! ( x, 1200 ) ;
18+ z . push ( 13 ) ;
19+ assert_eq ! ( x, [ 42 , 13 ] ) ;
2020 }
2121}
You can’t perform that action at this time.
0 commit comments