diff --git a/crates/gpui/playground/src/element.rs b/crates/gpui/playground/src/element.rs index 6091e17989fe54b7a95a27e1789e9eb3eef2fecd..741ba68317ae40f7c14b3bcbd7812024b0ecd3a0 100644 --- a/crates/gpui/playground/src/element.rs +++ b/crates/gpui/playground/src/element.rs @@ -71,22 +71,19 @@ impl> Default for ElementPhase { impl> AnyStatefulElement for StatefulElement { fn layout(&mut self, view: &mut V, cx: &mut LayoutContext) -> Result { let result; - self.phase = match std::mem::take(&mut self.phase) { - ElementPhase::Init => match self.element.layout(view, cx) { - Ok((layout_id, paint_state)) => { - result = Ok(layout_id); - ElementPhase::PostLayout { - layout_id, - paint_state, - } + self.phase = match self.element.layout(view, cx) { + Ok((layout_id, paint_state)) => { + result = Ok(layout_id); + ElementPhase::PostLayout { + layout_id, + paint_state, } - Err(error) => { - let message = error.to_string(); - result = Err(error); - ElementPhase::Error(message) - } - }, - _ => panic!("invalid element phase to call layout"), + } + Err(error) => { + let message = error.to_string(); + result = Err(error); + ElementPhase::Error(message) + } }; result