←back to thread

611 points LorenDB | 1 comments | | HN request time: 0s | source
Show context
codedokode ◴[] No.43908897[source]
What about catching integer overflow? Free open-source languages still cannot do it unlike they commercial competitors like Swift?
replies(5): >>43908922 #>>43909326 #>>43909444 #>>43910683 #>>43912986 #
kelnos ◴[] No.43909444[source]
Rust does have checked arithmetic operations (that return Result), but you have to explicitly opt in to them, of course, and they're not as ergonomic to use as regular arithmetic.
replies(2): >>43909660 #>>43913722 #
1. trealira ◴[] No.43909660[source]
But, by default, normal arithmetic operations trap on overflow in debug mode, although they wrap with optimizations on.