error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements --> src/main.rs:40:9 | 40 | num | ^^^ | note: first, the lifetime cannot outlive the anonymous lifetime #2 defined on the body at 37:44... --> src/main.rs:37:44 | 37 | let mut expensive_result = Cacher::new(|num| { | ____________________________________________^ 38 | | println!("calculating..."); 39 | | thread::sleep(Duration::from_secs(2)); 40 | | num 41 | | }); | |_____^ = note: ...so that the expression is assignable: expected &u32 found &u32 note: but, the lifetime must be valid for the call at 37:32... --> src/main.rs:37:32 | 37 | let mut expensive_result = Cacher::new(|num| { | ________________________________^ 38 | | println!("calculating..."); 39 | | thread::sleep(Duration::from_secs(2)); 40 | | num 41 | | }); | |______^ note: ...so type `Cacher<[closure@src/main.rs:37:44: 41:6], u32, &u32>` of expression is valid during the expression --> src/main.rs:37:32 | 37 | let mut expensive_result = Cacher::new(|num| { | ________________________________^ 38 | | println!("calculating..."); 39 | | thread::sleep(Duration::from_secs(2)); 40 | | num 41 | | }); | |______^ error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements --> src/main.rs:80:37 | 80 | let mut c = Cacher::new(|a| a); | ^ | note: first, the lifetime cannot outlive the anonymous lifetime #2 defined on the body at 80:33... --> src/main.rs:80:33 | 80 | let mut c = Cacher::new(|a| a); | ^^^^^ = note: ...so that the expression is assignable: expected &i32 found &i32 note: but, the lifetime must be valid for the call at 80:21... --> src/main.rs:80:21 | 80 | let mut c = Cacher::new(|a| a); | ^^^^^^^^^^^^^^^^^^ note: ...so type `Cacher<[closure@src/main.rs:80:33: 80:38], i32, &i32>` of expression is valid during the expression --> src/main.rs:80:21 | 80 | let mut c = Cacher::new(|a| a); | ^^^^^^^^^^^^^^^^^^ error: aborting due to 2 previous errors error: Could not compile `exercise-exercise`. To learn more, run the command again with --verbose.