diff --git a/crates/gpui/src/elements/text.rs b/crates/gpui/src/elements/text.rs index 770c1f871432afbecc9ffd4e903dfeddcfcba6ee..ab861be5a29fcbfb575a48cf743407f1c6e927d6 100644 --- a/crates/gpui/src/elements/text.rs +++ b/crates/gpui/src/elements/text.rs @@ -84,6 +84,14 @@ impl IntoElement for String { } } +impl IntoElement for Cow<'static, str> { + type Element = SharedString; + + fn into_element(self) -> Self::Element { + self.into() + } +} + impl Element for SharedString { type RequestLayoutState = TextLayout; type PrepaintState = (); @@ -924,3 +932,17 @@ impl IntoElement for InteractiveText { self } } + +#[cfg(test)] +mod tests { + #[test] + fn test_into_element_for() { + use crate::{ParentElement as _, SharedString, div}; + use std::borrow::Cow; + + let _ = div().child("static str"); + let _ = div().child("String".to_string()); + let _ = div().child(Cow::Borrowed("Cow")); + let _ = div().child(SharedString::from("SharedString")); + } +}