Rollup merge of #53271 - llogiq:simplify-maybe-map, r=joshtriplett

use ? to simplify `TransitiveRelation.maybe_map`

I think this looks much clearer than the original.
This commit is contained in:
Guillaume Gomez 2018-08-15 19:20:21 +02:00 committed by GitHub
commit b941c8e7fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -97,12 +97,7 @@ impl<T: Clone + Debug + Eq + Hash> TransitiveRelation<T> {
{
let mut result = TransitiveRelation::new();
for edge in &self.edges {
f(&self.elements[edge.source.0]).and_then(|source| {
f(&self.elements[edge.target.0]).and_then(|target| {
result.add(source, target);
Some(())
})
})?;
result.add(f(&self.elements[edge.source.0])?, f(&self.elements[edge.target.0])?);
}
Some(result)
}