4 ms·
To quote that reddit post, which I think has some good interesting details about why: “I believe the problem with ..= is that x..(y + 1) is not identical with
by bluejekyll 8y ago
To quote that reddit post, which I think has some good interesting details about why:
“I believe the problem with ..= is that x..(y + 1) is not identical with x..=y. They are nearly equivalent on most values for x and y, except when y == i32::max(). At that point, x..=y should still be able to function, while x..(y + 1) is allowed to do nothing.”
- SlowRobotAhead 8y agoI don't know anything about Rust, but is it part of it's "safety" that it has operators to allow rollover of type max size and others that do not? As a C programmer, that sort of feels like cheating ;)
- steveklabnik 8y agoSafety means "memory safety". Integer overflow cannot cause memory unsafety directly, and so it's safe. (safe) Rust does not claim to make your code correct, it claims that it will not have undefined behavior. We do care about helping you make your code correct; it will check for overflow and panic at runtime in debug builds. But it's a secondary concern. Memory safety is hard enough!