1 unstable release

0.1.0 Mar 13, 2020

#2168 in Rust patterns

Download history 59/week @ 2024-07-27 59/week @ 2024-08-03 34/week @ 2024-08-10 27/week @ 2024-08-17 88/week @ 2024-08-24 69/week @ 2024-08-31 29/week @ 2024-09-07 44/week @ 2024-09-14 80/week @ 2024-09-21 49/week @ 2024-09-28 57/week @ 2024-10-05 42/week @ 2024-10-12 90/week @ 2024-10-19 140/week @ 2024-10-26 66/week @ 2024-11-02 92/week @ 2024-11-09

393 downloads per month

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

~150KB