Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

gpui: Impl `Cow<'static, str>` to `IntoElement` (#48585)

Jason Lee13154e1b0ad0
diff --git a/crates/gpui/src/elements/text.rs b/crates/gpui/src/elements/text.rs
index 770c1f87143..ab861be5a29 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"));
+ }
+}