2 ms·
I'm not sure I'd characterize it as "jumping through hoops", but Rust does lean strongly towards preferring immutabillity. Variables are immutable unless you gi
by saghm 10y ago
I'm not sure I'd characterize it as "jumping through hoops", but Rust does lean strongly towards preferring immutabillity. Variables are immutable unless you give them the "mut" keyword when you declare them, and in cases where you need multiple pointers to the same data, it's impossible (outside of `unsafe` blocks, of course) to make one of them mutable unless you use a safe wrapper type like a`Cell` or `RefCell` (for single-threaded cases) or a `Mutex` or `RwLock` (for when you need to share access across multiple threads). But yeah, there's a strong bias towards immutability in Rust, although from what I understand this is more for safety than performance reasons.