, opts: &stv::STVOptions) -> String {
let mut result = String::from("Count complete. The winning candidates are, in order of election:
");
let mut winners = Vec::new();
for (candidate, count_card) in state.candidates.iter() {
if count_card.state == CandidateState::Elected {
winners.push((candidate, count_card.order_elected, &count_card.keep_value));
}
}
winners.sort_unstable_by(|a, b| a.1.cmp(&b.1));
for (winner, _, kv_opt) in winners.into_iter() {
if let Some(kv) = kv_opt {
result.push_str(&format!("- {} (kv = {:.dps2$})
", winner.name, kv, dps2=max(opts.pp_decimals, 2)));
} else {
result.push_str(&format!("- {}
", winner.name));
}
}
result.push_str("
");
return result;
}