pub fn progressive_tax_unchecked<T: FloatLike>(
agi: T,
deductions: T,
rate_table: &[(T, T)],
) -> TExpand description
Progressive Income Tax - Unchecked Version
This is an unchecked version of the progressive_tax function that skips the rate table validation, may provide
a performance boost in scenarios where the rate table is known to be valid.
§Arguments
agi- Adjusted Gross Income (AGI) for the tax year, your total income minus any above-the-line deductionsdeductions- Any below-the-line deductions for the tax year (i.e. standard or itemized deductions)rate_table- A slice of tuples representing the upper income of each bracket and its rate for the tax year(bracket, rate), the last tuple should represent a number to infinity and the highest rate. In practice, the final bracket would the maximum number representable by the type (FloatLike::MAX).
§Returns
- The total tax owed for the tax year based on the progressive rate table. If AGI is less than deductions, zero is returned (no tax owed).
§Examples
use rust_finprim::amort_dep_tax::progressive_tax;
let rate_table = vec![
(9_875.0, 0.10),
(40_125.0, 0.12),
(85_525.0, 0.22),
(163_300.0, 0.24),
(207_350.0, 0.32),
(518_400.0, 0.35),
(f64::MAX, 0.37)
];
let agi = 100_000.0;
let deductions = 12_000.0;
let tax = progressive_tax(agi, deductions, &rate_table);