From f4fdf64072c5d318cda8302c75d41437ba7d4213 Mon Sep 17 00:00:00 2001 From: RunasSudo Date: Sat, 29 May 2021 23:25:27 +1000 Subject: [PATCH] Show total vote in report --- src/main.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 971840c..8ecde45 100644 --- a/src/main.rs +++ b/src/main.rs @@ -113,8 +113,6 @@ where // Distribute first preferences stv::count_init(&mut state, &stv_opts); - - // Display let mut stage_num = 1; make_and_print_result(stage_num, &state, &cmd_opts); @@ -187,6 +185,11 @@ fn print_stage(stage_num: usize, result: &StageResult, cmd_opts: & println!("Exhausted: {:.dps$} ({:.dps$})", state.exhausted.votes, state.exhausted.transfers, dps=cmd_opts.pp_decimals); println!("Loss by fraction: {:.dps$} ({:.dps$})", state.loss_fraction.votes, state.loss_fraction.transfers, dps=cmd_opts.pp_decimals); + let mut total_vote = state.candidates.values().fold(N::zero(), |acc, cc| { acc + &cc.votes }); + total_vote += &state.exhausted.votes; + total_vote += &state.loss_fraction.votes; + println!("Total votes: {:.dps$}", total_vote, dps=cmd_opts.pp_decimals); + println!("Quota: {:.dps$}", state.quota, dps=cmd_opts.pp_decimals); println!("");