File tree 2 files changed +4
-3
lines changed
2 files changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -16,10 +16,11 @@ extern crate collections;
16
16
use std:: collections:: HashMap ;
17
17
18
18
fn main ( ) {
19
+ let tmp;
19
20
let mut buggy_map: HashMap < usize , & usize > = HashMap :: new ( ) ;
20
21
buggy_map. insert ( 42 , & * box 1 ) ; //~ ERROR borrowed value does not live long enough
21
22
22
23
// but it is ok if we use a temporary
23
- let tmp = box 2 ;
24
+ tmp = box 2 ;
24
25
buggy_map. insert ( 43 , & * tmp) ;
25
26
}
Original file line number Diff line number Diff line change 13
13
use std:: cell:: RefCell ;
14
14
15
15
fn main ( ) {
16
- let c = RefCell :: new ( vec ! [ ] ) ;
17
16
let mut y = 1 us;
17
+ let c = RefCell :: new ( vec ! [ ] ) ;
18
18
c. push ( box || y = 0 ) ;
19
19
c. push ( box || y = 0 ) ;
20
20
//~^ ERROR cannot borrow `y` as mutable more than once at a time
21
21
}
22
22
23
23
fn ufcs ( ) {
24
- let c = RefCell :: new ( vec ! [ ] ) ;
25
24
let mut y = 1 us;
25
+ let c = RefCell :: new ( vec ! [ ] ) ;
26
26
27
27
Push :: push ( & c, box || y = 0 ) ;
28
28
Push :: push ( & c, box || y = 0 ) ;
You can’t perform that action at this time.
0 commit comments