Skip to content

Instantly share code, notes, and snippets.

@shubhamkumar13
Last active October 5, 2022 10:49
Show Gist options
  • Select an option

  • Save shubhamkumar13/55b1da4c3ed5ff8d83c7458693d69007 to your computer and use it in GitHub Desktop.

Select an option

Save shubhamkumar13/55b1da4c3ed5ff8d83c7458693d69007 to your computer and use it in GitHub Desktop.
after_improved_code
// find the nearest cab in the fleet from the person
let mut nearest_cab = fleet
.into_iter()
.filter(|x| is_free((*x).clone()).is_ok())
.reduce(|c1, c2| person.nearest_cab(&c1, &c2))
.and_then(|x| Some(x.clone()))
.expect("Unable to get the nearest cab");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment