From dc0e423142f053c59c326d92920e7829b6852cca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Fri, 10 Jul 2020 02:01:30 +0200 Subject: [PATCH] Remove unnecessary lifetime in `Widget` trait --- examples/custom_widget/src/main.rs | 2 +- examples/geometry/src/main.rs | 2 +- graphics/src/renderer.rs | 2 +- graphics/src/widget/canvas.rs | 2 +- native/src/element.rs | 12 ++++++------ native/src/layout/debugger.rs | 2 +- native/src/overlay/menu.rs | 2 +- native/src/widget.rs | 8 ++++---- native/src/widget/button.rs | 2 +- native/src/widget/checkbox.rs | 2 +- native/src/widget/column.rs | 2 +- native/src/widget/combo_box.rs | 2 +- native/src/widget/container.rs | 2 +- native/src/widget/image.rs | 2 +- native/src/widget/pane_grid.rs | 2 +- native/src/widget/progress_bar.rs | 3 +-- native/src/widget/radio.rs | 3 +-- native/src/widget/row.rs | 2 +- native/src/widget/scrollable.rs | 2 +- native/src/widget/slider.rs | 2 +- native/src/widget/space.rs | 2 +- native/src/widget/svg.rs | 2 +- native/src/widget/text.rs | 2 +- native/src/widget/text_input.rs | 2 +- 24 files changed, 32 insertions(+), 34 deletions(-) diff --git a/examples/custom_widget/src/main.rs b/examples/custom_widget/src/main.rs index a6068f91..bcf896b0 100644 --- a/examples/custom_widget/src/main.rs +++ b/examples/custom_widget/src/main.rs @@ -25,7 +25,7 @@ mod circle { } } - impl<'a, Message, B> Widget<'a, Message, Renderer> for Circle + impl Widget> for Circle where B: Backend, { diff --git a/examples/geometry/src/main.rs b/examples/geometry/src/main.rs index 3795323a..71ce0d8c 100644 --- a/examples/geometry/src/main.rs +++ b/examples/geometry/src/main.rs @@ -27,7 +27,7 @@ mod rainbow { } } - impl<'a, Message, B> Widget<'a, Message, Renderer> for Rainbow + impl Widget> for Rainbow where B: Backend, { diff --git a/graphics/src/renderer.rs b/graphics/src/renderer.rs index 5ca6c057..5d51e6d4 100644 --- a/graphics/src/renderer.rs +++ b/graphics/src/renderer.rs @@ -93,7 +93,7 @@ where fn explain( &mut self, defaults: &Defaults, - widget: &dyn Widget<'_, Message, Self>, + widget: &dyn Widget, layout: Layout<'_>, cursor_position: Point, color: Color, diff --git a/graphics/src/widget/canvas.rs b/graphics/src/widget/canvas.rs index 0257f819..b8466239 100644 --- a/graphics/src/widget/canvas.rs +++ b/graphics/src/widget/canvas.rs @@ -134,7 +134,7 @@ impl> Canvas { } } -impl<'a, Message, P, B> Widget<'a, Message, Renderer> for Canvas +impl Widget> for Canvas where P: Program, B: Backend, diff --git a/native/src/element.rs b/native/src/element.rs index 8e0ab295..db95919a 100644 --- a/native/src/element.rs +++ b/native/src/element.rs @@ -17,7 +17,7 @@ use std::rc::Rc; /// [`Element`]: struct.Element.html #[allow(missing_debug_implementations)] pub struct Element<'a, Message, Renderer> { - pub(crate) widget: Box + 'a>, + pub(crate) widget: Box + 'a>, } impl<'a, Message, Renderer> Element<'a, Message, Renderer> @@ -29,7 +29,7 @@ where /// [`Element`]: struct.Element.html /// [`Widget`]: widget/trait.Widget.html pub fn new( - widget: impl Widget<'a, Message, Renderer> + 'a, + widget: impl Widget + 'a, ) -> Element<'a, Message, Renderer> { Element { widget: Box::new(widget), @@ -282,13 +282,13 @@ where } struct Map<'a, A, B, Renderer> { - widget: Box + 'a>, + widget: Box + 'a>, mapper: Rc B>, } impl<'a, A, B, Renderer> Map<'a, A, B, Renderer> { pub fn new( - widget: Box + 'a>, + widget: Box + 'a>, mapper: F, ) -> Map<'a, A, B, Renderer> where @@ -301,7 +301,7 @@ impl<'a, A, B, Renderer> Map<'a, A, B, Renderer> { } } -impl<'a, A, B, Renderer> Widget<'a, B, Renderer> for Map<'a, A, B, Renderer> +impl<'a, A, B, Renderer> Widget for Map<'a, A, B, Renderer> where Renderer: crate::Renderer + 'a, A: 'static, @@ -389,7 +389,7 @@ where } } -impl<'a, Message, Renderer> Widget<'a, Message, Renderer> +impl<'a, Message, Renderer> Widget for Explain<'a, Message, Renderer> where Renderer: crate::Renderer + layout::Debugger, diff --git a/native/src/layout/debugger.rs b/native/src/layout/debugger.rs index 9c58f4f1..e4b21609 100644 --- a/native/src/layout/debugger.rs +++ b/native/src/layout/debugger.rs @@ -18,7 +18,7 @@ pub trait Debugger: Renderer { fn explain( &mut self, defaults: &Self::Defaults, - widget: &dyn Widget<'_, Message, Self>, + widget: &dyn Widget, layout: Layout<'_>, cursor_position: Point, color: Color, diff --git a/native/src/overlay/menu.rs b/native/src/overlay/menu.rs index 24eaef38..8c5daae1 100644 --- a/native/src/overlay/menu.rs +++ b/native/src/overlay/menu.rs @@ -260,7 +260,7 @@ struct List<'a, T, Message, Renderer: self::Renderer> { style: ::Style, } -impl<'a, T, Message, Renderer: self::Renderer> Widget<'a, Message, Renderer> +impl<'a, T, Message, Renderer: self::Renderer> Widget for List<'a, T, Message, Renderer> where T: Clone + ToString, diff --git a/native/src/widget.rs b/native/src/widget.rs index 11952018..a7f279ed 100644 --- a/native/src/widget.rs +++ b/native/src/widget.rs @@ -97,7 +97,7 @@ use crate::{layout, overlay, Clipboard, Event, Hasher, Layout, Length, Point}; /// [`geometry`]: https://github.com/hecrj/iced/tree/0.1/examples/geometry /// [`lyon`]: https://github.com/nical/lyon /// [`iced_wgpu`]: https://github.com/hecrj/iced/tree/0.1/wgpu -pub trait Widget<'a, Message, Renderer> +pub trait Widget where Renderer: crate::Renderer, { @@ -179,10 +179,10 @@ where ) { } - fn overlay<'b>( - &'b mut self, + fn overlay( + &mut self, _layout: Layout<'_>, - ) -> Option> { + ) -> Option> { None } } diff --git a/native/src/widget/button.rs b/native/src/widget/button.rs index 72db808b..c932da2b 100644 --- a/native/src/widget/button.rs +++ b/native/src/widget/button.rs @@ -139,7 +139,7 @@ impl State { } } -impl<'a, Message, Renderer> Widget<'a, Message, Renderer> +impl<'a, Message, Renderer> Widget for Button<'a, Message, Renderer> where Renderer: self::Renderer, diff --git a/native/src/widget/checkbox.rs b/native/src/widget/checkbox.rs index 82fd6d1f..44962288 100644 --- a/native/src/widget/checkbox.rs +++ b/native/src/widget/checkbox.rs @@ -106,7 +106,7 @@ impl } } -impl<'a, Message, Renderer> Widget<'a, Message, Renderer> +impl Widget for Checkbox where Renderer: self::Renderer + text::Renderer + row::Renderer, diff --git a/native/src/widget/column.rs b/native/src/widget/column.rs index 83d5054f..42cfe9b9 100644 --- a/native/src/widget/column.rs +++ b/native/src/widget/column.rs @@ -121,7 +121,7 @@ impl<'a, Message, Renderer> Column<'a, Message, Renderer> { } } -impl<'a, Message, Renderer> Widget<'a, Message, Renderer> +impl<'a, Message, Renderer> Widget for Column<'a, Message, Renderer> where Renderer: self::Renderer, diff --git a/native/src/widget/combo_box.rs b/native/src/widget/combo_box.rs index e33eebfd..a9f0e6ed 100644 --- a/native/src/widget/combo_box.rs +++ b/native/src/widget/combo_box.rs @@ -93,7 +93,7 @@ where } } -impl<'a, T: 'a, Message, Renderer> Widget<'a, Message, Renderer> +impl<'a, T: 'a, Message, Renderer> Widget for ComboBox<'a, T, Message, Renderer> where T: Clone + ToString + Eq, diff --git a/native/src/widget/container.rs b/native/src/widget/container.rs index 0ee67db0..b8316e62 100644 --- a/native/src/widget/container.rs +++ b/native/src/widget/container.rs @@ -129,7 +129,7 @@ where } } -impl<'a, Message, Renderer> Widget<'a, Message, Renderer> +impl<'a, Message, Renderer> Widget for Container<'a, Message, Renderer> where Renderer: self::Renderer, diff --git a/native/src/widget/image.rs b/native/src/widget/image.rs index b7c8f4ff..132f249d 100644 --- a/native/src/widget/image.rs +++ b/native/src/widget/image.rs @@ -54,7 +54,7 @@ impl Image { } } -impl<'a, Message, Renderer> Widget<'a, Message, Renderer> for Image +impl Widget for Image where Renderer: self::Renderer, { diff --git a/native/src/widget/pane_grid.rs b/native/src/widget/pane_grid.rs index a8e1f852..0b237b9e 100644 --- a/native/src/widget/pane_grid.rs +++ b/native/src/widget/pane_grid.rs @@ -402,7 +402,7 @@ pub struct KeyPressEvent { pub modifiers: keyboard::ModifiersState, } -impl<'a, Message, Renderer> Widget<'a, Message, Renderer> +impl<'a, Message, Renderer> Widget for PaneGrid<'a, Message, Renderer> where Renderer: self::Renderer + container::Renderer, diff --git a/native/src/widget/progress_bar.rs b/native/src/widget/progress_bar.rs index 93d86371..5ab76d47 100644 --- a/native/src/widget/progress_bar.rs +++ b/native/src/widget/progress_bar.rs @@ -70,8 +70,7 @@ impl ProgressBar { } } -impl<'a, Message, Renderer> Widget<'a, Message, Renderer> - for ProgressBar +impl Widget for ProgressBar where Renderer: self::Renderer, { diff --git a/native/src/widget/radio.rs b/native/src/widget/radio.rs index 0d88c740..5b8d00e9 100644 --- a/native/src/widget/radio.rs +++ b/native/src/widget/radio.rs @@ -121,8 +121,7 @@ impl } } -impl<'a, Message, Renderer> Widget<'a, Message, Renderer> - for Radio +impl Widget for Radio where Renderer: self::Renderer + text::Renderer + row::Renderer, Message: Clone, diff --git a/native/src/widget/row.rs b/native/src/widget/row.rs index eda515b0..2b6db224 100644 --- a/native/src/widget/row.rs +++ b/native/src/widget/row.rs @@ -122,7 +122,7 @@ impl<'a, Message, Renderer> Row<'a, Message, Renderer> { } } -impl<'a, Message, Renderer> Widget<'a, Message, Renderer> +impl<'a, Message, Renderer> Widget for Row<'a, Message, Renderer> where Renderer: self::Renderer, diff --git a/native/src/widget/scrollable.rs b/native/src/widget/scrollable.rs index abd8cfbd..75e97027 100644 --- a/native/src/widget/scrollable.rs +++ b/native/src/widget/scrollable.rs @@ -110,7 +110,7 @@ impl<'a, Message, Renderer: self::Renderer> Scrollable<'a, Message, Renderer> { } } -impl<'a, Message, Renderer> Widget<'a, Message, Renderer> +impl<'a, Message, Renderer> Widget for Scrollable<'a, Message, Renderer> where Renderer: self::Renderer, diff --git a/native/src/widget/slider.rs b/native/src/widget/slider.rs index e0193342..70f2b6ac 100644 --- a/native/src/widget/slider.rs +++ b/native/src/widget/slider.rs @@ -154,7 +154,7 @@ impl State { } } -impl<'a, T, Message, Renderer> Widget<'a, Message, Renderer> +impl<'a, T, Message, Renderer> Widget for Slider<'a, T, Message, Renderer> where T: Copy + Into + num_traits::FromPrimitive, diff --git a/native/src/widget/space.rs b/native/src/widget/space.rs index 8ada40ed..f1576ffb 100644 --- a/native/src/widget/space.rs +++ b/native/src/widget/space.rs @@ -43,7 +43,7 @@ impl Space { } } -impl<'a, Message, Renderer> Widget<'a, Message, Renderer> for Space +impl Widget for Space where Renderer: self::Renderer, { diff --git a/native/src/widget/svg.rs b/native/src/widget/svg.rs index 3e45aaf6..114d5e41 100644 --- a/native/src/widget/svg.rs +++ b/native/src/widget/svg.rs @@ -60,7 +60,7 @@ impl Svg { } } -impl<'a, Message, Renderer> Widget<'a, Message, Renderer> for Svg +impl Widget for Svg where Renderer: self::Renderer, { diff --git a/native/src/widget/text.rs b/native/src/widget/text.rs index 7f75eb9c..48a69e34 100644 --- a/native/src/widget/text.rs +++ b/native/src/widget/text.rs @@ -112,7 +112,7 @@ impl Text { } } -impl<'a, Message, Renderer> Widget<'a, Message, Renderer> for Text +impl Widget for Text where Renderer: self::Renderer, { diff --git a/native/src/widget/text_input.rs b/native/src/widget/text_input.rs index 63be6019..3f415101 100644 --- a/native/src/widget/text_input.rs +++ b/native/src/widget/text_input.rs @@ -165,7 +165,7 @@ impl<'a, Message, Renderer: self::Renderer> TextInput<'a, Message, Renderer> { } } -impl<'a, Message, Renderer> Widget<'a, Message, Renderer> +impl<'a, Message, Renderer> Widget for TextInput<'a, Message, Renderer> where Renderer: self::Renderer,