use gpui3::Element; pub trait ElementExt: Element { /// Applies a given function `then` to the current element if `condition` is true. /// This function is used to conditionally modify the element based on a given condition. /// If `condition` is false, it just returns the current element as it is. fn when(mut self, condition: bool, then: impl FnOnce(Self) -> Self) -> Self where Self: Sized, { if condition { self = then(self); } self } // fn when_some(mut self, option: Option, then: impl FnOnce(Self, T) -> U) -> U // where // Self: Sized, // { // if let Some(value) = option { // self = then(self, value); // } // self // } } impl> ElementExt for E {}