1 #### Note: this error code is no longer emitted by the compiler.
3 The type does not fulfill the required lifetime.
5 Erroneous code example:
14 fn i_want_static_closure<F>(a: F)
15 where F: Fn() + 'static {}
17 fn print_string<'a>(s: Mutex<MyString<'a>>) {
19 i_want_static_closure(move || { // error: this closure has lifetime 'a
20 // rather than 'static
21 println!("{}", s.lock().unwrap().data);
26 In this example, the closure does not satisfy the `'static` lifetime constraint.
27 To fix this error, you need to double check the lifetime of the type. Here, we
28 can fix this problem by giving `s` a static lifetime:
37 fn i_want_static_closure<F>(a: F)
38 where F: Fn() + 'static {}
40 fn print_string(s: Mutex<MyString<'static>>) {
42 i_want_static_closure(move || { // ok!
43 println!("{}", s.lock().unwrap().data);