From 314463be063ab8130a6f1da117a7b12ab2b50e7e Mon Sep 17 00:00:00 2001 From: dimtpap Date: Sun, 27 Oct 2024 11:01:01 +0200 Subject: [PATCH] Impl from Box for WidgetText, RichText --- crates/egui/src/widget_text.rs | 35 ++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/crates/egui/src/widget_text.rs b/crates/egui/src/widget_text.rs index 03b8cbb9751..80ee6f05124 100644 --- a/crates/egui/src/widget_text.rs +++ b/crates/egui/src/widget_text.rs @@ -67,6 +67,27 @@ impl From for RichText { } } +impl From<&Box> for RichText { + #[inline] + fn from(text: &Box) -> Self { + Self::new(text.clone()) + } +} + +impl From<&mut Box> for RichText { + #[inline] + fn from(text: &mut Box) -> Self { + Self::new(text.clone()) + } +} + +impl From> for RichText { + #[inline] + fn from(text: Box) -> Self { + Self::new(text) + } +} + impl From> for RichText { #[inline] fn from(text: Cow<'_, str>) -> Self { @@ -701,6 +722,20 @@ impl From for WidgetText { } } +impl From<&Box> for WidgetText { + #[inline] + fn from(text: &Box) -> Self { + Self::RichText(RichText::new(text.clone())) + } +} + +impl From> for WidgetText { + #[inline] + fn from(text: Box) -> Self { + Self::RichText(RichText::new(text)) + } +} + impl From> for WidgetText { #[inline] fn from(text: Cow<'_, str>) -> Self {