3 ms·
Speaking of syntax: for x in &mut something { *x = (*x) * 2; }; Not Rust user but would not it make sense for compiler to understand x instead of *x i
by FpUser 4y ago
Speaking of syntax:
for x in &mut something {
*x = (*x) * 2;
};
Not Rust user but would not it make sense for compiler to understand x instead of *x in this situation? I thought it is considered higher level language than C.
- estebank 4y agoThe syntax discriminates between "changing the value where the reference points to" and "changing where the reference points to". The code is doing the former. The second use of * could be made unnecessary if the standard library had an impl Mul<u32> for &mut u32 {}.