It can still crash
It can still crash
Posted Feb 14, 2025 12:01 UTC (Fri) by tialaramex (subscriber, #21167)In reply to: It can still crash by milesrout
Parent article: Maintainer opinions on Rust-for-Linux
This will also happen if you use an operator, take AddAssign the trait implementing the += operator
description += " and then I woke up.";
... Is eventually just AddAssign::add_assign(&mut description, " and then I woke up.");
So if we lent out any reference to description that's still outstanding, we can't do this, likewise if we only have an immutable reference we can't use that to do this either. But the visible syntax shows no sign that this is the case.
In practice because humans are fallible, the most important thing is that this is checked by the compiler. It's valuable to know that my_function takes a mutable reference, when you're writing the software, when you're reading software other people wrote, and most definitely when re-reading your own software - but it's *most* valuable that the compiler checks because I might miss that, all three times.