diff --git a/packages/core/src/scopes.rs b/packages/core/src/scopes.rs index 652371bfc..b1dd41bca 100644 --- a/packages/core/src/scopes.rs +++ b/packages/core/src/scopes.rs @@ -97,11 +97,10 @@ impl ScopeArena { // Get the height of the scope let height = parent_scope - .map(|id| self.get_scope(id).map(|scope| scope.height + 1)) - .flatten() + .and_then(|id| self.get_scope(id).map(|scope| scope.height + 1)) .unwrap_or_default(); - let parent_scope = parent_scope.map(|f| self.get_scope_raw(f)).flatten(); + let parent_scope = parent_scope.and_then(|f| self.get_scope_raw(f)); /* This scopearena aggressively reuses old scopes when possible. @@ -659,8 +658,7 @@ impl ScopeState { self.shared_contexts .borrow_mut() .insert(TypeId::of::(), value.clone()) - .map(|f| f.downcast::().ok()) - .flatten(); + .and_then(|f| f.downcast::().ok()); value } @@ -690,8 +688,7 @@ impl ScopeState { self.shared_contexts .borrow_mut() .insert(TypeId::of::(), value.clone()) - .map(|f| f.downcast::().ok()) - .flatten(); + .and_then(|f| f.downcast::().ok()); return value; }