File tree Expand file tree Collapse file tree 1 file changed +13
-7
lines changed Expand file tree Collapse file tree 1 file changed +13
-7
lines changed Original file line number Diff line number Diff line change @@ -29,14 +29,20 @@ fn main() {
2929 borrow_i32(&boxed_i32);
3030 borrow_i32(&stacked_i32);
3131
32- // Take a reference to the data contained inside the box
33- let _ref_to_i32: &i32 = &boxed_i32;
32+ {
33+ // Take a reference to the data contained inside the box
34+ let _ref_to_i32: &i32 = &boxed_i32;
3435
35- // Can't destroy `boxed_i32` while the inner value is borrowed later in scope.
36- eat_box_i32(boxed_i32);
37- // FIXME ^ Comment out this line
36+ // Can't destroy `boxed_i32` while the inner value is borrowed later in scope.
37+ eat_box_i32(boxed_i32);
38+ // FIXME ^ Comment out this line
39+
40+ // Attempt to borrow `_ref_to_i32` after inner value is destroyed
41+ borrow_i32(_ref_to_i32);
42+ // `_ref_to_i32` goes out of scope and is no longer borrowed.
43+ }
3844
39- // Attempt to borrow `_ref_to_i32` after inner value is destroyed
40- borrow_i32(_ref_to_i32 );
45+ // `boxed_i32` can now give up ownership to `eat_box` and be destroyed
46+ eat_box_i32(boxed_i32 );
4147}
4248```
You can’t perform that action at this time.
0 commit comments