Support rich text convert from cow-string. (#1774)
This commit is contained in:
parent
5f364795cc
commit
14ae4b24a7
1 changed files with 15 additions and 0 deletions
|
@ -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 {
|
||||||
|
|
Loading…
Reference in a new issue