4 ms·
No, Rust has pointer arithmetic, though it's bounds checked with slices. The restriction is that two mutable references cannot point to the same location. This
by pcwalton 13y ago
No, Rust has pointer arithmetic, though it's bounds checked with slices. The restriction is that two mutable references cannot point to the same location. This is enforced by the borrow check: http://pcwalton.github.io/blog/2013/01/21/the-new-borrow-check-in-a-nutshell/ http://pcwalton.github.io/blog/2013/01/21/the-new-borrow-che...
- joosters 13y agoThanks!
- mcguire 13y agoAt compile time or run time?
- pcwalton 13y agoBounds checked at runtime (unless you use the unsafe sublanguage). Without dependent types (which I feel would exceed our complexity budget) we can't do much better. However, for simple iteration, if you use iterators idiomatically instead of C-style for loops then you won't incur any bounds checks.
- mcguire 13y agoI was just about to accuse you of dependent typing.