An open API service indexing awesome lists of open source software.

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

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.