I'm struggling to implement concurrency in my small learning app and I think I've hit a wall; I could really use some advice to help me understand why I'm stuck and maybe a kind soul to get me to working code.
I'm working with code in this PR and I have worked my way through many, many compiler errors which were all helpful learning experiences. The wall that I have hit is at the very end when I try to return
Ok with a vector of a custom struct.
This is the offending line and it is giving me the following error:
✦ ❯ cargo run -- -c corrator.toml -f text Compiling corrator v0.1.1 (/Users/ncox/src/natecox/corrator) error[E0507]: cannot move out of dereference of `MutexGuard<'_, std::vec::Vec<container::Status>>` --> src/lib.rs:80:8 | 80 | Ok(*data.lock().unwrap()) | ^^^^^^^^^^^^^^^^^^^^^ move occurs because value has type `std::vec::Vec<container::Status>`, which does not implement the `Copy` trait error[E0597]: `data` does not live long enough --> src/lib.rs:80:9 | 80 | Ok(*data.lock().unwrap()) | ^^^^^^^^^^^--------- | | | borrowed value does not live long enough | a temporary with access to the borrow is created here ... 81 | } | - | | | `data` dropped here while still borrowed | ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `MutexGuard` | = note: the temporary is part of an expression at the end of a block; consider forcing this temporary to be dropped sooner, before the block's local variables are dropped help: for example, you could save the expression's value in a new local variable `x` and then make `x` be the expression at the end of the block | 80 | let x = Ok(*data.lock().unwrap()); x | +++++++ +++ Some errors have detailed explanations: E0507, E0597. For more information about an error, try `rustc --explain E0507`. error: could not compile `corrator` due to 2 previous errors
I'm not really understanding why a move is happening there so I'm not sure where to go next. I would really appreciate some help here.