Skip to content

Commit

Permalink
feat: aircraft hashmap, tests, better error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
cathaypacific8747 committed May 30, 2024
1 parent f94f9c9 commit e6896ad
Show file tree
Hide file tree
Showing 9 changed files with 373 additions and 219 deletions.
21 changes: 21 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 11 additions & 10 deletions am4-cli/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
// use am4::airport::Airports;
use am4::aircraft::Aircrafts;
// use am4::aircraft::Aircrafts;
use am4::airport::Airports;
// use std::rc::Rc;

fn main() {
// NOTE: directory is CWD, not the location of the executable.
// let airports = Airports::from_csv("am4/data/airports.csv").unwrap();
let airports = Airports::from_csv("am4/data/airports.csv").unwrap();
// println!("{:#?}", airports);

// let a1 = airports.search("vhhh");
// let a2 = airports.search("iata:hkg");
// println!("{:?}", Rc::ptr_eq(a1.unwrap(), a2.unwrap()));
// println!("{:#?} {:#?}", y, y2);
let a1 = airports.search("iata:hkgA");
let suggestions = airports.suggest("iata:hkgA");

println!("{:#?}", suggestions)

// let x = airports.suggest("vhhh");
// println!("{:?}", x);

let aircrafts = Aircrafts::from_csv("am4/data/aircrafts.csv").unwrap();
// let aircrafts = Aircrafts::from_csv("am4/data/aircrafts.csv").unwrap();
// println!("{:#?}", aircrafts);
println!("{:#?}", aircrafts.search("a388").unwrap());
println!("{:#?}", aircrafts.search("a388[sfc]").unwrap());
// println!("{:#?}", aircrafts.by_id.len());
// println!("{:#?}", aircrafts.search("a388[s]").unwrap());
// println!("{:#?}", aircrafts.search_variants("a388").unwrap());
}
1 change: 1 addition & 0 deletions am4/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ edition = "2021"
csv = "1.3.0"
jaro_winkler = "0.1.0"
serde = { version = "1.0.203", features = ["derive"] }
thiserror = "1.0.61"
Loading

0 comments on commit e6896ad

Please sign in to comment.