3 ms·
Edit: Gah, I'm a bit wrong too. There's the compiler error (this), and the runtime error (what I'm talking about below.) Here's a link to the runtime variant:
by deathanatos 4y ago
Edit: Gah, I'm a bit wrong too. There's the compiler error (this), and the runtime error (what I'm talking about below.)
Here's a link to the runtime variant: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=6e1c0a18458154610ba8ac83065ea97c https://play.rust-lang.org/?version=stable&mode=debug&editio...
As a sibling notes, currently, this is for debug builds. So, if you change that playground to "Release", you'll see it wrap.
(I love this feature, and I wish they had done it in release mode too. The sibling comment has some notes on that, too.)
(But, e.g., were `git` written in Rust, presumably the end product would be a release build. Now, you can enable the check there, but that is something you have to do, today.)
(But also note, that, in all cases, it's well-defined. Vs. C, where some overflows are UB.)