`safe-math` is now on crates.io – Write regular math in Rust, with overflow checks and no panics
Hi everyone!
Last week I shared a preview of safe-math. This proc macro lets you write normal arithmetic expressions (a + b * c / d) while automatically checking all operations for overflow and underflow.
Thanks to your feedback and ideas, I'm happy to announce that it's now live on crates.io, with broader support and new features.
What's included in the first release
- Full support for all arithmetic ops:
+,-,*,/,% - Works with all unsigned and signed integers:
u8..=u128,usize,i8..=i128,isize - Float support (
f32,f64), with checks forNaNand±inf - Support for custom numeric types via the optional
derivefeature
🙏 Thanks + feedback welcome
I really appreciate all the comments on the first post, it helped me improve the macro and the overall quality of the code.
Now that it’s more complete, I’d love to hear your thoughts:
- Does the syntax feel ergonomic in real-world code?
- Are there edge cases or pain points I should address?
------
📦 Crate on crates.io
Thanks again — and happy hacking! 🦀