The Condvar
docs shows an example that includes the following:
let pair = Arc::new((Mutex::new(false), Condvar::new()));
// <snipped for brevity>
let &(ref lock, ref cvar) = &*pair;
I'm wondering what the advantage might be to including &
on both sides of this assignment. In other words, why not just write:
let (ref lock, ref cvar) = *pair;
Both versions compile; is there any semantic difference? And if not, is there any reason to prefer the syntax that appears in the example?
In general, I'm still struggling to understand when/where &*
should idiomatically appear in Rust code. My instinct is to "see" (read) this character combination as a no-op, though I understand that because of Rust's Deref
semantics this isn't the case.