From e03de019881f31d69b70a64c3e278ae5200d5080 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Thu, 10 Feb 2022 23:16:21 +0700 Subject: Implement `Into` for `&'static str` in `iced_virtual` --- virtual/src/widget/button.rs | 4 ++-- virtual/src/widget/column.rs | 11 +++++++++++ virtual/src/widget/text.rs | 9 +++++++++ 3 files changed, 22 insertions(+), 2 deletions(-) (limited to 'virtual/src/widget') diff --git a/virtual/src/widget/button.rs b/virtual/src/widget/button.rs index 534dd13a..ece90811 100644 --- a/virtual/src/widget/button.rs +++ b/virtual/src/widget/button.rs @@ -23,9 +23,9 @@ pub struct Button { } impl Button { - pub fn new(content: impl Widget + 'static) -> Self { + pub fn new(content: impl Into>) -> Self { Button { - content: Element::new(content), + content: content.into(), on_press: None, style_sheet: Default::default(), width: Length::Shrink, diff --git a/virtual/src/widget/column.rs b/virtual/src/widget/column.rs index e7649bc1..2f70282a 100644 --- a/virtual/src/widget/column.rs +++ b/virtual/src/widget/column.rs @@ -207,3 +207,14 @@ where } } } + +impl Into> + for Column +where + Message: 'static, + Renderer: iced_native::Renderer + 'static, +{ + fn into(self) -> Element { + Element::new(self) + } +} diff --git a/virtual/src/widget/text.rs b/virtual/src/widget/text.rs index 91da7e99..e3a7d299 100644 --- a/virtual/src/widget/text.rs +++ b/virtual/src/widget/text.rs @@ -174,3 +174,12 @@ where Element::new(self) } } + +impl Into> for &'static str +where + Renderer: text::Renderer + 'static, +{ + fn into(self) -> Element { + Text::new(self).into() + } +} -- cgit