1 unstable release

0.1.0 Mar 13, 2020

#2160 in Rust patterns

Download history 79/week @ 2024-07-22 50/week @ 2024-07-29 54/week @ 2024-08-05 31/week @ 2024-08-12 26/week @ 2024-08-19 112/week @ 2024-08-26 49/week @ 2024-09-02 28/week @ 2024-09-09 47/week @ 2024-09-16 77/week @ 2024-09-23 55/week @ 2024-09-30 51/week @ 2024-10-07 44/week @ 2024-10-14 114/week @ 2024-10-21 122/week @ 2024-10-28 72/week @ 2024-11-04

358 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