Skip to content

API Reference

Rule

pub enum Rule {
    Pure,          // reduce by fault share, no cut-off
    Modified50,    // barred at fault >= 0.50
    Modified51,    // barred at fault > 0.50
    Contributory,  // any fault bars recovery
}

Rule::bars_recovery(fault: f64) -> bool

Whether fault (a fraction in 0.0..=1.0) bars recovery under this rule.

net_recovery(gross: f64, fault: f64, rule: Rule) -> f64

Net recovery after applying the claimant's fault share. fault is clamped to 0.0..=1.0. Returns 0.0 when recovery is barred, or when gross <= 0.0.

reduction_amount(gross: f64, fault: f64, rule: Rule) -> f64

The dollar amount lost to the claimant's own fault share. Always complements net_recovery: the two sum to gross whenever recovery is not barred.

bar_threshold(rule: Rule) -> Option<f64>

The fault share at which recovery first becomes zero, or None for Rule::Pure, which has no cut-off.

Floating point

Fault shares are f64 fractions rather than percentages. Compare results with an epsilon rather than ==; 100_000.0 * (1.0 - 0.90) is 9999.999999999998, not 10000.0.