expression

Integer minor units for fixed-scale amounts

Represent same-currency, same-scale amounts with integer minor units when appropriate. Define rounding for division, currency conversion and tax separately; guard overflow. Expected stdout (not executed): Some(400) Common mistake: Not every currency has two decimal places; integer minor units alone do not implement financial rules.

Formal Syntax & Structure

rust syntaxrust
amount_in_minor_units: i64; x.checked_add(y)

Working Example

Example Snippetrust
fn main() {    let items = [125_i64, 240, 35];    let total = items.into_iter().try_fold(0_i64, i64::checked_add);    println!("{:?}", total);}
Rust Reference