Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

If you want to check for overflow, then you can use the methods that explicitly check for overflow:

https://doc.rust-lang.org/std/primitive.u32.html#method.chec...

So this is not an issue at all.




They are long to type and hard to read. They are so inconvenient to use that nobody uses them, even developers of Rust. Take source code of Vec as an example [1]. They use wrapping addition instead of checked one.

For comparison, in Swift normal arithmetic operations check for overflow.

[1] https://doc.rust-lang.org/src/alloc/vec/mod.rs.html#1773




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: