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 {
8
8
// Don't add, change or remove any line.
9
9
#[ test]
10
10
fn move_semantics4 ( ) {
11
- let mut x = 100 ;
11
+ let mut x = Vec :: new ( ) ;
12
12
let y = & mut x;
13
13
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 ] ) ;
17
17
}
18
18
}
Original file line number Diff line number Diff line change @@ -7,15 +7,15 @@ mod tests {
7
7
// TODO: Fix the compiler errors only by reordering the lines in the test.
8
8
// Don't add, change or remove any line.
9
9
#[ test]
10
- fn move_semantics5 ( ) {
11
- let mut x = 100 ;
10
+ fn move_semantics4 ( ) {
11
+ let mut x = Vec :: new ( ) ;
12
12
let y = & mut x;
13
13
// `y` used here.
14
- * y += 100 ;
14
+ y . push ( 42 ) ;
15
15
// The mutable reference `y` is not used anymore,
16
16
// therefore a new reference can be created.
17
17
let z = & mut x;
18
- * z += 1000 ;
19
- assert_eq ! ( x, 1200 ) ;
18
+ z . push ( 13 ) ;
19
+ assert_eq ! ( x, [ 42 , 13 ] ) ;
20
20
}
21
21
}
You can’t perform that action at this time.
0 commit comments