4 ms·
Weird question, where is the restrict keyword in Rust?
by frozenport 11y ago
Weird question, where is the restrict keyword in Rust?
- kibwen 11y agoRust doesn't need such a mechanism, because by default Rust already has an enormous wealth of bulletproof data regarding the aliasing that goes on in your program. Controlling aliasing is in some sense what Rust is all about! :)
- shepmaster 11y agoIf I understand the keyword correctly, it's not really needed in Rust. The Rust compiler keeps very close track of who has a reference (many immutable or one mutable) to a value. There isn't really "accidental" aliasing.
- Too 11y agoThat's awesome. It feels like this alone could, at least theoretically, make rust faster than C on average. Most C programmers are not even aware that the restrict keyword exists and don't use it in places where they could greatly benefit from it.
- pcwalton 11y ago&mut implies restrict.