diff --git a/crates/gpui2/src/element.rs b/crates/gpui2/src/element.rs index 3c8f678b89..b876e375da 100644 --- a/crates/gpui2/src/element.rs +++ b/crates/gpui2/src/element.rs @@ -69,6 +69,24 @@ pub trait IntoElement: Sized { self.map(|this| if condition { then(this) } else { this }) } + fn when_else( + self, + condition: bool, + then: impl FnOnce(Self) -> Self, + otherwise: impl FnOnce(Self) -> Self, + ) -> Self + where + Self: Sized, + { + self.map(|this| { + if condition { + then(this) + } else { + otherwise(this) + } + }) + } + fn when_some(self, option: Option, then: impl FnOnce(Self, T) -> Self) -> Self where Self: Sized,