3 ms·
The compiler ensures that you can only take one &mut reference at a time. You can have as many immutable `&` references as you want, because you can't change an
by Ar-Curunir 8y ago
The compiler ensures that you can only take one &mut reference at a time. You can have as many immutable `&` references as you want, because you can't change anything through those references (unless you do some unsafe trickery)
- cesarb 8y ago> you can only take one &mut reference at a time. You can have as many immutable `&` references as you want There's another small detail: these two cases are mutually exclusive. You can either have one &mut reference, or as many & references as you want. This means that code receiving a & reference can be sure the object won't change, and that code receiving a &mut reference knows the object can be modified safely since nothing else could be looking at it. (Assuming the object doesn't contain a Cell, the rules are a bit different when a Cell is involved.)