upgrade to rust 2018 and some other fixes
[Mitarbeiter/Tim-Zeitz/stud-rust-base.git] / src / bin / example.rs
1 use stud_rust_base::{
2     types::*,
3     io::*,
4     time::report_time,
5 };
6
7 use std::{env, path::Path};
8
9 fn main() {
10     let mut args = env::args();
11     args.next();
12
13     let arg = &args.next().expect("No directory arg given");
14     let path = Path::new(arg);
15
16     let first_out = Vec::<EdgeId>::load_from(path.join("first_out").to_str().unwrap()).expect("could not read first_out");
17     let head = Vec::<NodeId>::load_from(path.join("head").to_str().unwrap()).expect("could not read head");
18     let travel_time = Vec::<Weight>::load_from(path.join("travel_time").to_str().unwrap()).expect("could not read travel_time");
19
20     report_time("iterating over arcs of some node", || {
21         let node_id = 42;
22         for edge_id in first_out[node_id] .. first_out[node_id + 1] {
23             println!("There is an arc from {} to {} with weight {}", node_id, head[edge_id as usize], travel_time[edge_id as usize]);
24         }
25     });
26
27     vec![42; 42].write_to(path.join("distances").to_str().unwrap()).expect("could not write distances");
28 }