https://github.com/kamadak/checked_ops-rs
Automatic checked arithmetic operations in Rust
https://github.com/kamadak/checked_ops-rs
checked-arithmetic integer-overflow rust
Last synced: about 1 year ago
JSON representation
Automatic checked arithmetic operations in Rust
- Host: GitHub
- URL: https://github.com/kamadak/checked_ops-rs
- Owner: kamadak
- Created: 2020-03-13T12:44:14.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2020-04-04T14:54:06.000Z (almost 6 years ago)
- Last Synced: 2025-02-28T06:33:53.559Z (about 1 year ago)
- Topics: checked-arithmetic, integer-overflow, rust
- Language: Rust
- Size: 9.77 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README
Awesome Lists containing this project
README
Automatic checked arithmetic operations in Rust
-----------------------------------------------
Are you tired of writing checked arithmetic operations like this?
a.checked_add(b).and_then(|t| t.checked_mul(c))
The checked_ops crate to the rescue.
checked_ops!((a + b) * c)
Usage
-----
Add a dependency entry to your Cargo.toml.
[dependencies]
checked_ops = "0.1"
Import the macro into your source code.
use checked_ops::checked_ops;
Use the macro.
checked_ops!((a + b) * c)
Dependencies
------------
Rust 1.34 or later is required.