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:
commit
b941c8e7fb
@ -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)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user