3 ms·
Rust is tricky. Took me about a year to grok decently. Regarding references, the compiler does flow analysis and tries to enforce a sort of static rwlock seman
by strictfp 6y ago
Rust is tricky. Took me about a year to grok decently.
Regarding references, the compiler does flow analysis and tries to enforce a sort of static rwlock semantic on variable level. You either have a single mutable reference xor N readable references to the same variable.
If b is a mutable reference to a, c cannot point to a until b reliquishes the "lock", which happens when b goes out of scope.