Answers for "rust•armanriazi•error•[E0382]: use of moved value: `counter` value moved into closure here, in previous iteration of loop"

0

rust•armanriazi•error•[E0382]: use of moved value: `counter` value moved into closure here, in previous iteration of loop

Rust is telling us that we can’t move the ownership of lock counter into multiple threads. Let’s fix the compiler error with a multiple-ownership(like RC) method 
Fortunately, Arc<T> is a type like Rc<T> that is safe to use in concurrent situations
    let counter = Arc::new(Mutex::new(0));
    let counter = Arc::clone(&counter);
Posted by: Guest on March-25-2022

Code answers related to "rust•armanriazi•error•[E0382]: use of moved value: `counter` value moved into closure here, in previous iteration of loop"

Browse Popular Code Answers by Language