Skip to content

Commit

Permalink
Impl from Box<str> for WidgetText, RichText
Browse files Browse the repository at this point in the history
  • Loading branch information
dimtpap committed Oct 27, 2024
1 parent 5b846b4 commit 314463b
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions crates/egui/src/widget_text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,27 @@ impl From<String> for RichText {
}
}

impl From<&Box<str>> for RichText {
#[inline]
fn from(text: &Box<str>) -> Self {
Self::new(text.clone())
}
}

impl From<&mut Box<str>> for RichText {
#[inline]
fn from(text: &mut Box<str>) -> Self {
Self::new(text.clone())
}
}

impl From<Box<str>> for RichText {
#[inline]
fn from(text: Box<str>) -> Self {
Self::new(text)
}
}

impl From<Cow<'_, str>> for RichText {
#[inline]
fn from(text: Cow<'_, str>) -> Self {
Expand Down Expand Up @@ -701,6 +722,20 @@ impl From<String> for WidgetText {
}
}

impl From<&Box<str>> for WidgetText {
#[inline]
fn from(text: &Box<str>) -> Self {
Self::RichText(RichText::new(text.clone()))
}
}

impl From<Box<str>> for WidgetText {
#[inline]
fn from(text: Box<str>) -> Self {
Self::RichText(RichText::new(text))
}
}

impl From<Cow<'_, str>> for WidgetText {
#[inline]
fn from(text: Cow<'_, str>) -> Self {
Expand Down

0 comments on commit 314463b

Please sign in to comment.