Skip to content

Examples

Every figure below is reproducible with cargo run, or against the WorthMyClaim settlement estimator.

The 50/51 divergence

use comparative_fault::{net_recovery, Rule};

let gross = 100_000.0;
let fault = 0.50;

assert_eq!(net_recovery(gross, fault, Rule::Modified50), 0.0);       // barred
assert!((net_recovery(gross, fault, Rule::Modified51) - 50_000.0).abs() < 1e-6);

Pure comparative has no floor

use comparative_fault::{net_recovery, Rule};

// 90% at fault still recovers 10%.
assert!((net_recovery(100_000.0, 0.90, Rule::Pure) - 10_000.0).abs() < 1e-6);

Contributory negligence

use comparative_fault::{net_recovery, Rule};

assert_eq!(net_recovery(100_000.0, 0.01, Rule::Contributory), 0.0);
assert_eq!(net_recovery(100_000.0, 0.0,  Rule::Contributory), 100_000.0);

Reduction complements recovery

use comparative_fault::{net_recovery, reduction_amount, Rule};

let g = 250_000.0;
for f in [0.0, 0.10, 0.25, 0.49] {
    let net = net_recovery(g, f, Rule::Modified51);
    let cut = reduction_amount(g, f, Rule::Modified51);
    assert!((net + cut - g).abs() < 1e-6);
}