financial-ops-macros
Procedural macros for financial-ops.
This crate provides the checked! macro, which recursively rewrites an
arithmetic expression into a chain of the standard library's checked arithmetic
methods while preserving operator precedence and grouping.
You normally don't depend on this crate directly — the macro is re-exported as
financial_ops::checked.
use checked;
// Respects precedence: this is `a + (b * c)`, fully checked.
let value: = checked! ;
assert_eq!;
// Overflow short-circuits to `None`.
assert_eq!;
// With `@ <error>` you get a `Result<T, E>`, where `E` is just the type of the
// expression you pass — a string literal makes `E = &str`, no external crate
// (e.g. anyhow) required.
let result: = checked! ;
assert_eq!;