financial-ops-macros 1.0.0

Procedural macros for `financial-ops`: recursive compile-time checked arithmetic.
Documentation
  • Coverage
  • 100%
    2 out of 2 items documented0 out of 1 items with examples
  • Size
  • Source code size: 9.98 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 290.76 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 7s Average build duration of successful builds.
  • all releases: 7s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • 0xC0A1/financial-ops
    7 1 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • 0xC0A1

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 financial_ops::checked;

// Respects precedence: this is `a + (b * c)`, fully checked.
let value: Option<u64> = checked! { 2u64 + 3 * 4 };
assert_eq!(value, Some(14));

// Overflow short-circuits to `None`.
assert_eq!(checked! { u8::MAX + 1u8 }, None);

// With `@ error`, you get a `Result` instead.
let result = checked! { 2u64 + 2 @ "overflow" };
assert_eq!(result, Ok(4));