Created
October 5, 2022 10:41
-
-
Save shubhamkumar13/04e824f045f658e79c7d5148fd874b61 to your computer and use it in GitHub Desktop.
before_wrong_code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// find the nearest cab in the fleet from the person | |
let mut nearest_cab = fleet | |
.into_iter() | |
.reduce(|c1, c2| person.nearest_cab(&c1, &c2)) | |
.and_then(|x| Some(x.clone())) | |
.expect("Unable to get the nearest cab"); | |
// check if the cab is assigned or not | |
match is_free(nearest_cab.clone()) { | |
Ok(_) => { | |
// update cab destination and person_id | |
nearest_cab.update_destination(Some(person.location.clone())); | |
nearest_cab.update_person_id(ObjectId::parse_str(person_id).ok()); | |
// update cab by using `assign_person` | |
.... | |
.... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment