Support rich text convert from cow-string.
+use std::borrow::Cow;
use std::sync::Arc;
use crate::{
@@ -65,6 +66,13 @@ impl From<String> for RichText {
}
}
+impl From<Cow<'_, str>> for RichText {
+ #[inline]
+ fn from(text: Cow<'_, str>) -> Self {
+ Self::new(text)
+ }
+}
+
impl RichText {
#[inline]
pub fn new(text: impl Into<String>) -> Self {
@@ -605,6 +613,13 @@ impl From<String> for WidgetText {
}
}
+impl From<Cow<'_, str>> for WidgetText {
+ #[inline]
+ fn from(text: Cow<'_, str>) -> Self {
+ Self::RichText(RichText::new(text))
+ }
+}
+
impl From<RichText> for WidgetText {
#[inline]
fn from(rich_text: RichText) -> Self {
