From f7d7ab1ba9a037be6bf2a32f7b2662e5314ae3a5 Mon Sep 17 00:00:00 2001 From: Olivier Pinon Date: Sun, 12 Apr 2020 00:40:51 +0200 Subject: [PATCH 1/3] Remove unnecessary 'static lifetime on Renderer --- native/src/widget/button.rs | 7 ++++--- native/src/widget/checkbox.rs | 7 ++++--- native/src/widget/column.rs | 7 ++++--- native/src/widget/container.rs | 7 ++++--- native/src/widget/pane_grid.rs | 7 ++++--- native/src/widget/progress_bar.rs | 7 ++++--- native/src/widget/radio.rs | 7 ++++--- native/src/widget/row.rs | 7 ++++--- native/src/widget/scrollable.rs | 7 ++++--- native/src/widget/slider.rs | 7 ++++--- native/src/widget/text_input.rs | 8 ++++---- 11 files changed, 44 insertions(+), 34 deletions(-) diff --git a/native/src/widget/button.rs b/native/src/widget/button.rs index 7b5c349c..409ec41d 100644 --- a/native/src/widget/button.rs +++ b/native/src/widget/button.rs @@ -143,7 +143,7 @@ impl State { impl<'a, Message, Renderer> Widget for Button<'a, Message, Renderer> where - Renderer: 'static + self::Renderer, + Renderer: self::Renderer, Message: Clone, { fn width(&self) -> Length { @@ -234,7 +234,8 @@ where } fn hash_layout(&self, state: &mut Hasher) { - std::any::TypeId::of::>().hash(state); + struct ButtonWidget; + std::any::TypeId::of::().hash(state); self.width.hash(state); self.content.hash_layout(state); @@ -276,7 +277,7 @@ pub trait Renderer: crate::Renderer + Sized { impl<'a, Message, Renderer> From> for Element<'a, Message, Renderer> where - Renderer: 'static + self::Renderer, + Renderer: 'a + self::Renderer, Message: 'a + Clone, { fn from( diff --git a/native/src/widget/checkbox.rs b/native/src/widget/checkbox.rs index ccf13848..482e379f 100644 --- a/native/src/widget/checkbox.rs +++ b/native/src/widget/checkbox.rs @@ -110,7 +110,7 @@ impl impl Widget for Checkbox where - Renderer: 'static + self::Renderer + text::Renderer + row::Renderer, + Renderer: self::Renderer + text::Renderer + row::Renderer, { fn width(&self) -> Length { self.width @@ -205,7 +205,8 @@ where } fn hash_layout(&self, state: &mut Hasher) { - std::any::TypeId::of::>().hash(state); + struct CheckboxWidget; + std::any::TypeId::of::().hash(state); self.label.hash(state); } @@ -254,7 +255,7 @@ pub trait Renderer: crate::Renderer { impl<'a, Message, Renderer> From> for Element<'a, Message, Renderer> where - Renderer: 'static + self::Renderer + text::Renderer + row::Renderer, + Renderer: 'a + self::Renderer + text::Renderer + row::Renderer, Message: 'a, { fn from( diff --git a/native/src/widget/column.rs b/native/src/widget/column.rs index 77b8496b..ee02244d 100644 --- a/native/src/widget/column.rs +++ b/native/src/widget/column.rs @@ -124,7 +124,7 @@ impl<'a, Message, Renderer> Column<'a, Message, Renderer> { impl<'a, Message, Renderer> Widget for Column<'a, Message, Renderer> where - Renderer: 'static + self::Renderer, + Renderer: self::Renderer, { fn width(&self) -> Length { self.width @@ -190,7 +190,8 @@ where } fn hash_layout(&self, state: &mut Hasher) { - std::any::TypeId::of::>().hash(state); + struct ColumnWidget; + std::any::TypeId::of::().hash(state); self.width.hash(state); self.height.hash(state); @@ -234,7 +235,7 @@ pub trait Renderer: crate::Renderer + Sized { impl<'a, Message, Renderer> From> for Element<'a, Message, Renderer> where - Renderer: 'static + self::Renderer, + Renderer: 'a + self::Renderer, Message: 'a, { fn from( diff --git a/native/src/widget/container.rs b/native/src/widget/container.rs index 34032c3a..3b661c05 100644 --- a/native/src/widget/container.rs +++ b/native/src/widget/container.rs @@ -132,7 +132,7 @@ where impl<'a, Message, Renderer> Widget for Container<'a, Message, Renderer> where - Renderer: 'static + self::Renderer, + Renderer: self::Renderer, { fn width(&self) -> Length { self.width @@ -203,7 +203,8 @@ where } fn hash_layout(&self, state: &mut Hasher) { - std::any::TypeId::of::>().hash(state); + struct ContainerWidget; + std::any::TypeId::of::().hash(state); self.padding.hash(state); self.width.hash(state); @@ -243,7 +244,7 @@ pub trait Renderer: crate::Renderer { impl<'a, Message, Renderer> From> for Element<'a, Message, Renderer> where - Renderer: 'static + self::Renderer, + Renderer: 'a + self::Renderer, Message: 'a, { fn from( diff --git a/native/src/widget/pane_grid.rs b/native/src/widget/pane_grid.rs index f6dd328e..01b008da 100644 --- a/native/src/widget/pane_grid.rs +++ b/native/src/widget/pane_grid.rs @@ -356,7 +356,7 @@ pub struct KeyPressEvent { impl<'a, Message, Renderer> Widget for PaneGrid<'a, Message, Renderer> where - Renderer: 'static + self::Renderer, + Renderer: self::Renderer, { fn width(&self) -> Length { self.width @@ -597,8 +597,9 @@ where fn hash_layout(&self, state: &mut Hasher) { use std::hash::Hash; + struct PaneGridWidget; + std::any::TypeId::of::().hash(state); - std::any::TypeId::of::>().hash(state); self.width.hash(state); self.height.hash(state); self.state.hash_layout(state); @@ -643,7 +644,7 @@ pub trait Renderer: crate::Renderer + Sized { impl<'a, Message, Renderer> From> for Element<'a, Message, Renderer> where - Renderer: 'static + self::Renderer, + Renderer: 'a + self::Renderer, Message: 'a, { fn from( diff --git a/native/src/widget/progress_bar.rs b/native/src/widget/progress_bar.rs index 897edb30..0e6e9367 100644 --- a/native/src/widget/progress_bar.rs +++ b/native/src/widget/progress_bar.rs @@ -72,7 +72,7 @@ impl ProgressBar { impl Widget for ProgressBar where - Renderer: 'static + self::Renderer, + Renderer: self::Renderer, { fn width(&self) -> Length { self.width @@ -114,7 +114,8 @@ where } fn hash_layout(&self, state: &mut Hasher) { - std::any::TypeId::of::>().hash(state); + struct ProgressBarWidget; + std::any::TypeId::of::().hash(state); self.width.hash(state); self.height.hash(state); @@ -159,7 +160,7 @@ pub trait Renderer: crate::Renderer { impl<'a, Message, Renderer> From> for Element<'a, Message, Renderer> where - Renderer: 'static + self::Renderer, + Renderer: 'a + self::Renderer, Message: 'a, { fn from( diff --git a/native/src/widget/radio.rs b/native/src/widget/radio.rs index bc23c116..c1e36e3d 100644 --- a/native/src/widget/radio.rs +++ b/native/src/widget/radio.rs @@ -82,7 +82,7 @@ impl Radio { impl Widget for Radio where - Renderer: 'static + self::Renderer + text::Renderer + row::Renderer, + Renderer: self::Renderer + text::Renderer + row::Renderer, Message: Clone, { fn width(&self) -> Length { @@ -174,7 +174,8 @@ where } fn hash_layout(&self, state: &mut Hasher) { - std::any::TypeId::of::>().hash(state); + struct RadioWidget; + std::any::TypeId::of::().hash(state); self.label.hash(state); } @@ -218,7 +219,7 @@ pub trait Renderer: crate::Renderer { impl<'a, Message, Renderer> From> for Element<'a, Message, Renderer> where - Renderer: 'static + self::Renderer + row::Renderer + text::Renderer, + Renderer: 'a + self::Renderer + row::Renderer + text::Renderer, Message: 'a + Clone, { fn from(radio: Radio) -> Element<'a, Message, Renderer> { diff --git a/native/src/widget/row.rs b/native/src/widget/row.rs index 5f139f66..405ba001 100644 --- a/native/src/widget/row.rs +++ b/native/src/widget/row.rs @@ -125,7 +125,7 @@ impl<'a, Message, Renderer> Row<'a, Message, Renderer> { impl<'a, Message, Renderer> Widget for Row<'a, Message, Renderer> where - Renderer: 'static + self::Renderer, + Renderer: self::Renderer, { fn width(&self) -> Length { self.width @@ -191,7 +191,8 @@ where } fn hash_layout(&self, state: &mut Hasher) { - std::any::TypeId::of::>().hash(state); + struct RowWidget; + std::any::TypeId::of::().hash(state); self.width.hash(state); self.height.hash(state); @@ -236,7 +237,7 @@ pub trait Renderer: crate::Renderer + Sized { impl<'a, Message, Renderer> From> for Element<'a, Message, Renderer> where - Renderer: 'static + self::Renderer, + Renderer: 'a + self::Renderer, Message: 'a, { fn from(row: Row<'a, Message, Renderer>) -> Element<'a, Message, Renderer> { diff --git a/native/src/widget/scrollable.rs b/native/src/widget/scrollable.rs index ba39edb1..f1506a3e 100644 --- a/native/src/widget/scrollable.rs +++ b/native/src/widget/scrollable.rs @@ -115,7 +115,7 @@ impl<'a, Message, Renderer: self::Renderer> Scrollable<'a, Message, Renderer> { impl<'a, Message, Renderer> Widget for Scrollable<'a, Message, Renderer> where - Renderer: 'static + self::Renderer + column::Renderer, + Renderer: self::Renderer + column::Renderer, { fn width(&self) -> Length { Widget::::width(&self.content) @@ -311,7 +311,8 @@ where } fn hash_layout(&self, state: &mut Hasher) { - std::any::TypeId::of::>().hash(state); + struct ScrollableWidget; + std::any::TypeId::of::().hash(state); self.height.hash(state); self.max_height.hash(state); @@ -505,7 +506,7 @@ pub trait Renderer: crate::Renderer + Sized { impl<'a, Message, Renderer> From> for Element<'a, Message, Renderer> where - Renderer: 'static + self::Renderer + column::Renderer, + Renderer: 'a + self::Renderer + column::Renderer, Message: 'a, { fn from( diff --git a/native/src/widget/slider.rs b/native/src/widget/slider.rs index b2fa5c9d..3e8c836e 100644 --- a/native/src/widget/slider.rs +++ b/native/src/widget/slider.rs @@ -114,7 +114,7 @@ impl State { impl<'a, Message, Renderer> Widget for Slider<'a, Message, Renderer> where - Renderer: 'static + self::Renderer, + Renderer: self::Renderer, { fn width(&self) -> Length { self.width @@ -205,7 +205,8 @@ where } fn hash_layout(&self, state: &mut Hasher) { - std::any::TypeId::of::>().hash(state); + struct SliderWidget; + std::any::TypeId::of::().hash(state); self.width.hash(state); } @@ -253,7 +254,7 @@ pub trait Renderer: crate::Renderer { impl<'a, Message, Renderer> From> for Element<'a, Message, Renderer> where - Renderer: 'static + self::Renderer, + Renderer: 'a + self::Renderer, Message: 'a, { fn from( diff --git a/native/src/widget/text_input.rs b/native/src/widget/text_input.rs index ae3d74ae..7a171d57 100644 --- a/native/src/widget/text_input.rs +++ b/native/src/widget/text_input.rs @@ -171,7 +171,7 @@ impl<'a, Message, Renderer: self::Renderer> TextInput<'a, Message, Renderer> { impl<'a, Message, Renderer> Widget for TextInput<'a, Message, Renderer> where - Renderer: 'static + self::Renderer, + Renderer: self::Renderer, Message: Clone, { fn width(&self) -> Length { @@ -526,8 +526,8 @@ where fn hash_layout(&self, state: &mut Hasher) { use std::{any::TypeId, hash::Hash}; - - TypeId::of::>().hash(state); + struct TextInputWidget; + TypeId::of::().hash(state); self.width.hash(state); self.max_width.hash(state); @@ -632,7 +632,7 @@ pub trait Renderer: crate::Renderer + Sized { impl<'a, Message, Renderer> From> for Element<'a, Message, Renderer> where - Renderer: 'static + self::Renderer, + Renderer: 'a + self::Renderer, Message: 'a + Clone, { fn from( From 41f6a325e9b6c9df18ab2c3bcf386be988f4b4ef Mon Sep 17 00:00:00 2001 From: Olivier Pinon Date: Sun, 12 Apr 2020 01:20:40 +0200 Subject: [PATCH 2/3] #288 Renamed XXXWidget to Marker --- native/src/widget/button.rs | 4 ++-- native/src/widget/checkbox.rs | 4 ++-- native/src/widget/column.rs | 4 ++-- native/src/widget/container.rs | 4 ++-- native/src/widget/image.rs | 3 ++- native/src/widget/pane_grid.rs | 4 ++-- native/src/widget/progress_bar.rs | 4 ++-- native/src/widget/radio.rs | 4 ++-- native/src/widget/row.rs | 4 ++-- native/src/widget/scrollable.rs | 4 ++-- native/src/widget/slider.rs | 4 ++-- 11 files changed, 22 insertions(+), 21 deletions(-) diff --git a/native/src/widget/button.rs b/native/src/widget/button.rs index 409ec41d..3cf4f780 100644 --- a/native/src/widget/button.rs +++ b/native/src/widget/button.rs @@ -234,8 +234,8 @@ where } fn hash_layout(&self, state: &mut Hasher) { - struct ButtonWidget; - std::any::TypeId::of::().hash(state); + struct Marker; + std::any::TypeId::of::().hash(state); self.width.hash(state); self.content.hash_layout(state); diff --git a/native/src/widget/checkbox.rs b/native/src/widget/checkbox.rs index 482e379f..d611993f 100644 --- a/native/src/widget/checkbox.rs +++ b/native/src/widget/checkbox.rs @@ -205,8 +205,8 @@ where } fn hash_layout(&self, state: &mut Hasher) { - struct CheckboxWidget; - std::any::TypeId::of::().hash(state); + struct Marker; + std::any::TypeId::of::().hash(state); self.label.hash(state); } diff --git a/native/src/widget/column.rs b/native/src/widget/column.rs index ee02244d..259a7e6e 100644 --- a/native/src/widget/column.rs +++ b/native/src/widget/column.rs @@ -190,8 +190,8 @@ where } fn hash_layout(&self, state: &mut Hasher) { - struct ColumnWidget; - std::any::TypeId::of::().hash(state); + struct Marker; + std::any::TypeId::of::().hash(state); self.width.hash(state); self.height.hash(state); diff --git a/native/src/widget/container.rs b/native/src/widget/container.rs index 3b661c05..2590fe3b 100644 --- a/native/src/widget/container.rs +++ b/native/src/widget/container.rs @@ -203,8 +203,8 @@ where } fn hash_layout(&self, state: &mut Hasher) { - struct ContainerWidget; - std::any::TypeId::of::().hash(state); + struct Marker; + std::any::TypeId::of::().hash(state); self.padding.hash(state); self.width.hash(state); diff --git a/native/src/widget/image.rs b/native/src/widget/image.rs index 0f38a90e..6bd0fd68 100644 --- a/native/src/widget/image.rs +++ b/native/src/widget/image.rs @@ -102,7 +102,8 @@ where } fn hash_layout(&self, state: &mut Hasher) { - std::any::TypeId::of::().hash(state); + struct Marker; + std::any::TypeId::of::().hash(state); self.handle.hash(state); self.width.hash(state); diff --git a/native/src/widget/pane_grid.rs b/native/src/widget/pane_grid.rs index 01b008da..f84775ed 100644 --- a/native/src/widget/pane_grid.rs +++ b/native/src/widget/pane_grid.rs @@ -597,8 +597,8 @@ where fn hash_layout(&self, state: &mut Hasher) { use std::hash::Hash; - struct PaneGridWidget; - std::any::TypeId::of::().hash(state); + struct Marker; + std::any::TypeId::of::().hash(state); self.width.hash(state); self.height.hash(state); diff --git a/native/src/widget/progress_bar.rs b/native/src/widget/progress_bar.rs index 0e6e9367..5ab76d47 100644 --- a/native/src/widget/progress_bar.rs +++ b/native/src/widget/progress_bar.rs @@ -114,8 +114,8 @@ where } fn hash_layout(&self, state: &mut Hasher) { - struct ProgressBarWidget; - std::any::TypeId::of::().hash(state); + struct Marker; + std::any::TypeId::of::().hash(state); self.width.hash(state); self.height.hash(state); diff --git a/native/src/widget/radio.rs b/native/src/widget/radio.rs index c1e36e3d..0ec621bf 100644 --- a/native/src/widget/radio.rs +++ b/native/src/widget/radio.rs @@ -174,8 +174,8 @@ where } fn hash_layout(&self, state: &mut Hasher) { - struct RadioWidget; - std::any::TypeId::of::().hash(state); + struct Marker; + std::any::TypeId::of::().hash(state); self.label.hash(state); } diff --git a/native/src/widget/row.rs b/native/src/widget/row.rs index 405ba001..31f7472f 100644 --- a/native/src/widget/row.rs +++ b/native/src/widget/row.rs @@ -191,8 +191,8 @@ where } fn hash_layout(&self, state: &mut Hasher) { - struct RowWidget; - std::any::TypeId::of::().hash(state); + struct Marker; + std::any::TypeId::of::().hash(state); self.width.hash(state); self.height.hash(state); diff --git a/native/src/widget/scrollable.rs b/native/src/widget/scrollable.rs index f1506a3e..393095a4 100644 --- a/native/src/widget/scrollable.rs +++ b/native/src/widget/scrollable.rs @@ -311,8 +311,8 @@ where } fn hash_layout(&self, state: &mut Hasher) { - struct ScrollableWidget; - std::any::TypeId::of::().hash(state); + struct Marker; + std::any::TypeId::of::().hash(state); self.height.hash(state); self.max_height.hash(state); diff --git a/native/src/widget/slider.rs b/native/src/widget/slider.rs index 3e8c836e..1feb7825 100644 --- a/native/src/widget/slider.rs +++ b/native/src/widget/slider.rs @@ -205,8 +205,8 @@ where } fn hash_layout(&self, state: &mut Hasher) { - struct SliderWidget; - std::any::TypeId::of::().hash(state); + struct Marker; + std::any::TypeId::of::().hash(state); self.width.hash(state); } From 5e47238489471ee3da3ea125c8ee7926ab221079 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Mon, 13 Apr 2020 04:38:35 +0200 Subject: [PATCH 3/3] Rename leftover `TextInputWidget` to `Marker` --- native/src/widget/text_input.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/native/src/widget/text_input.rs b/native/src/widget/text_input.rs index 7a171d57..7d1a7415 100644 --- a/native/src/widget/text_input.rs +++ b/native/src/widget/text_input.rs @@ -526,8 +526,8 @@ where fn hash_layout(&self, state: &mut Hasher) { use std::{any::TypeId, hash::Hash}; - struct TextInputWidget; - TypeId::of::().hash(state); + struct Marker; + TypeId::of::().hash(state); self.width.hash(state); self.max_width.hash(state);