Mutable reference syntax
⚓ Rust 📅 2025-10-18 👤 surdeus 👁️ 2Why was &mut x chosen over mut &x for mutable references?
I find the syntax &mut x for mutable references less readable than a hypothetical mut &x. With &x, the & is directly before the variable name, clearly indicating a reference. Adding mut to form mut &x would preserve this structure, keeping & next to the variable for better visual consistency and easier scanning. However, &mut x shifts & left and introduces a space, making it harder to quickly recognize the reference.
Were there historical discussions or design decisions (e.g., during pre-1.0 development or "mutpocalypse") that considered mut &x as an alternative? If not, why was &mut x preferred, despite its impact on readability?
3 posts - 3 participants
🏷️ Rust_feed