diff --git a/egui/src/widget_text.rs b/egui/src/widget_text.rs index f7d11b0d..df535684 100644 --- a/egui/src/widget_text.rs +++ b/egui/src/widget_text.rs @@ -1,3 +1,4 @@ +use std::borrow::Cow; use std::sync::Arc; use crate::{ @@ -65,6 +66,13 @@ impl From for RichText { } } +impl From> for RichText { + #[inline] + fn from(text: Cow<'_, str>) -> Self { + Self::new(text) + } +} + impl RichText { #[inline] pub fn new(text: impl Into) -> Self { @@ -605,6 +613,13 @@ impl From for WidgetText { } } +impl From> for WidgetText { + #[inline] + fn from(text: Cow<'_, str>) -> Self { + Self::RichText(RichText::new(text)) + } +} + impl From for WidgetText { #[inline] fn from(rich_text: RichText) -> Self {