1 Borrowed data escapes outside of closure.
3 Erroneous code example:
6 let mut list: Vec<&str> = Vec::new();
8 let _add = |el: &str| {
9 list.push(el); // error: `el` escapes the closure body here
13 A type anotation of a closure parameter implies a new lifetime declaration.
14 Consider to drop it, the compiler is reliably able to infer them.
17 let mut list: Vec<&str> = Vec::new();
24 See the [Closure type inference and annotation][closure-infere-annotation] and
25 [Lifetime elision][lifetime-elision] sections of the Book for more details.
27 [closure-infere-annotation]: https://doc.rust-lang.org/book/ch13-01-closures.html#closure-type-inference-and-annotation
28 [lifetime-elision]: https://doc.rust-lang.org/reference/lifetime-elision.html