split and snap
This commit is contained in:
parent
c78520ee65
commit
999aa5d329
7 changed files with 636 additions and 642 deletions
46
src/report.rs
Normal file
46
src/report.rs
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
use std::collections::HashSet;
|
||||
|
||||
use crate::crossings::Crossing;
|
||||
|
||||
pub fn print_report(crossings: &[Crossing]) {
|
||||
eprintln!();
|
||||
eprintln!("County visits");
|
||||
eprintln!("=============");
|
||||
|
||||
if crossings.is_empty() {
|
||||
eprintln!("No county crossings found.");
|
||||
return;
|
||||
}
|
||||
|
||||
let mut visits = Vec::new();
|
||||
|
||||
visits.push(crossings[0].from.clone());
|
||||
|
||||
for crossing in crossings {
|
||||
visits.push(crossing.to.clone());
|
||||
}
|
||||
|
||||
for (index, county) in visits.iter().enumerate() {
|
||||
eprintln!("{:3} {} [{}]", index + 1, county.name, county.id,);
|
||||
}
|
||||
|
||||
let unique: HashSet<String> = visits.iter().map(|county| county.id.clone()).collect();
|
||||
|
||||
eprintln!();
|
||||
eprintln!("Visits: {}", visits.len());
|
||||
|
||||
eprintln!("Unique counties: {}", unique.len());
|
||||
|
||||
eprintln!();
|
||||
eprintln!("Border crossings");
|
||||
eprintln!("=================");
|
||||
|
||||
for (index, crossing) in crossings.iter().enumerate() {
|
||||
eprintln!(
|
||||
"{:3} {} -> {}",
|
||||
index + 1,
|
||||
crossing.from.name,
|
||||
crossing.to.name,
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue