) -> 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));
}
}
winners.sort_unstable_by(|a, b| a.1.partial_cmp(&b.1).unwrap());
for (winner, _) in winners.into_iter() {
result.push_str(&format!("- {}
", winner.name));
}
result.push_str("
");
return result;
}
fn pp(n: &N, dps: usize) -> String {
if n.is_zero() {
return "".to_string();
}
let mut raw = format!("{:.dps$}", n, dps=dps);
if raw.contains('.') {
raw = raw.replacen(".", ".", 1);
raw.push_str("");
}
if raw.starts_with('-') {
raw = raw.replacen("-", "−", 1);
}
return raw;
}