1 unstable release

0.1.0 Mar 13, 2020

#25 in #checked

BSD-2-Clause

15KB
182 lines

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)

lib.rs:

Automatic checked arithmetic operations in Rust.

The checked_ops macro takes an expression and expands it into a checked form. You no longer need to type:

a.checked_add(b).and_then(|t| t.checked_mul(c))

You can just do:

checked_ops!((a + b) * c)

The current implementation has several limitations. See the documentation of checked_ops macro for details.

Dependencies

~155KB