I'm looking at the Condvar
example and am curious how the tuples pair
and pair2
are destructured:
let pair = Arc::new((Mutex::new(false), Condvar::new()));
let pair2 = pair.clone();
// ...
thread::spawn(move|| {
let &(ref lock, ref cvar) = &*pair2;
// ...
}
Doesn't Arc
's Deref
implementation return a reference to the inner data? But removing the &
from pair2
:
let &(ref lock, ref cvar) = *pair2;
gives a compiler error:
11 | let &(ref lock, ref cvar) = *pair2;
| ^^^^^^^^^^^^^^^^^^^^^ expected tuple, found reference
|
= note: expected type `(std::sync::Mutex<bool>, std::sync::Condvar)`
found type `&_`
This seems to imply that *pair2
returns a tuple and not a reference.