I am using code_to_id lmao

main
Zynh0722 2024-04-25 19:09:42 -07:00
parent e922599372
commit ba5642063e
1 changed files with 3 additions and 3 deletions

View File

@ -10,15 +10,15 @@ airport-paths -h
); );
} }
pub fn handle_args(args: Vec<String>, _code_to_id: HashMap<String, usize>) -> (usize, usize) { pub fn handle_args(args: Vec<String>, code_to_id: HashMap<String, usize>) -> (usize, usize) {
let (origin, destination) = match args.len() { let (origin, destination) = match args.len() {
3 => { 3 => {
let exit_handler = || { let exit_handler = || {
println!("unable to find airport"); println!("unable to find airport");
exit(2); exit(2);
}; };
let origin = _code_to_id.get(&args[1]).unwrap_or_else(exit_handler); let origin = code_to_id.get(&args[1]).unwrap_or_else(exit_handler);
let destination = _code_to_id.get(&args[2]).unwrap_or_else(exit_handler); let destination = code_to_id.get(&args[2]).unwrap_or_else(exit_handler);
(origin, destination) (origin, destination)
} }