3 ms·
Possibly! Remember that the Rust language and C/C++ have different semantics with regards to overflow. It may be the programmer's "fault" for not writing the co
by steveklabnik 8y ago
Possibly! Remember that the Rust language and C/C++ have different semantics with regards to overflow. It may be the programmer's "fault" for not writing the code with the equivalent semantics (you can make them have the same semantics, but it's not the default).
- stabbles 8y agoLooking at the Rust source [1] it seems there the `next()` call has some overhead, so it's probably not the compiler. I remember this was simple to implement in Julia [2] where you can iterate over the full range `for i = typemin(Int):typemax(Int) ... end` without overflow and without overhead. Same should be possible in Rust I think. [1] https://doc.rust-lang.org/src/core/iter/range.rs.html#340-353 https://doc.rust-lang.org/src/core/iter/range.rs.html#340-35... [2] https://github.com/JuliaLang/julia/blob/master/base/range.jl#L591-L598 https://github.com/JuliaLang/julia/blob/master/base/range.jl...