error[E0521]: borrowed data escapes outside of closure
--> src/tests/fail/move_out_stream_error.rs:8:5
|
5 | let stream_error = Mutex::new(Option::<StreamError>::None);
| ------------ `stream_error` declared here, outside of the closure body
6 | let mut _handler = {
7 | move |_: &Context, _: &mut Connection, _: i32, _: i32, err: Option<StreamError>| {
| --- `err` is a reference that is only valid in the closure body
8 | *stream_error.lock().unwrap() = err;
| ^^^^^^^^^^^^^^^^^^^ `err` escapes the closure body here
|
= note: requirement occurs because of the type `Mutex<Option<StreamError<'_, '_>>>`, which makes the generic argument `Option<StreamError<'_, '_>>` invariant
= note: the struct `Mutex<T>` is invariant over the parameter `T`
= help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance