1
0
mirror of https://github.com/emilk/egui.git synced 2026-09-02 14:50:03 -04:00

Support rich text convert from cow-string. (#1774)

This commit is contained in:
Yuan Chang
2022-07-03 21:16:05 +08:00
committed by GitHub
parent 5f364795cc
commit 14ae4b24a7

View File

@@ -1,3 +1,4 @@
use std::borrow::Cow;
use std::sync::Arc; use std::sync::Arc;
use crate::{ 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 { impl RichText {
#[inline] #[inline]
pub fn new(text: impl Into<String>) -> Self { 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 { impl From<RichText> for WidgetText {
#[inline] #[inline]
fn from(rich_text: RichText) -> Self { fn from(rich_text: RichText) -> Self {