Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unnecessary 'static lifetimes on Renderer traits #290

Merged
merged 3 commits into from
Apr 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions native/src/widget/button.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ impl State {
impl<'a, Message, Renderer> Widget<Message, Renderer>
for Button<'a, Message, Renderer>
where
Renderer: 'static + self::Renderer,
Renderer: self::Renderer,
Message: Clone,
{
fn width(&self) -> Length {
Expand Down Expand Up @@ -234,7 +234,8 @@ where
}

fn hash_layout(&self, state: &mut Hasher) {
std::any::TypeId::of::<Button<'_, (), Renderer>>().hash(state);
struct Marker;
std::any::TypeId::of::<Marker>().hash(state);

self.width.hash(state);
self.content.hash_layout(state);
Expand Down Expand Up @@ -276,7 +277,7 @@ pub trait Renderer: crate::Renderer + Sized {
impl<'a, Message, Renderer> From<Button<'a, Message, Renderer>>
for Element<'a, Message, Renderer>
where
Renderer: 'static + self::Renderer,
Renderer: 'a + self::Renderer,
Message: 'a + Clone,
{
fn from(
Expand Down
7 changes: 4 additions & 3 deletions native/src/widget/checkbox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ impl<Message, Renderer: self::Renderer + text::Renderer>
impl<Message, Renderer> Widget<Message, Renderer>
for Checkbox<Message, Renderer>
where
Renderer: 'static + self::Renderer + text::Renderer + row::Renderer,
Renderer: self::Renderer + text::Renderer + row::Renderer,
{
fn width(&self) -> Length {
self.width
Expand Down Expand Up @@ -205,7 +205,8 @@ where
}

fn hash_layout(&self, state: &mut Hasher) {
std::any::TypeId::of::<Checkbox<(), Renderer>>().hash(state);
struct Marker;
std::any::TypeId::of::<Marker>().hash(state);

self.label.hash(state);
}
Expand Down Expand Up @@ -254,7 +255,7 @@ pub trait Renderer: crate::Renderer {
impl<'a, Message, Renderer> From<Checkbox<Message, Renderer>>
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(
Expand Down
7 changes: 4 additions & 3 deletions native/src/widget/column.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ impl<'a, Message, Renderer> Column<'a, Message, Renderer> {
impl<'a, Message, Renderer> Widget<Message, Renderer>
for Column<'a, Message, Renderer>
where
Renderer: 'static + self::Renderer,
Renderer: self::Renderer,
{
fn width(&self) -> Length {
self.width
Expand Down Expand Up @@ -190,7 +190,8 @@ where
}

fn hash_layout(&self, state: &mut Hasher) {
std::any::TypeId::of::<Column<'_, (), Renderer>>().hash(state);
struct Marker;
std::any::TypeId::of::<Marker>().hash(state);

self.width.hash(state);
self.height.hash(state);
Expand Down Expand Up @@ -234,7 +235,7 @@ pub trait Renderer: crate::Renderer + Sized {
impl<'a, Message, Renderer> From<Column<'a, Message, Renderer>>
for Element<'a, Message, Renderer>
where
Renderer: 'static + self::Renderer,
Renderer: 'a + self::Renderer,
Message: 'a,
{
fn from(
Expand Down
7 changes: 4 additions & 3 deletions native/src/widget/container.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ where
impl<'a, Message, Renderer> Widget<Message, Renderer>
for Container<'a, Message, Renderer>
where
Renderer: 'static + self::Renderer,
Renderer: self::Renderer,
{
fn width(&self) -> Length {
self.width
Expand Down Expand Up @@ -203,7 +203,8 @@ where
}

fn hash_layout(&self, state: &mut Hasher) {
std::any::TypeId::of::<Container<'_, (), Renderer>>().hash(state);
struct Marker;
std::any::TypeId::of::<Marker>().hash(state);

self.padding.hash(state);
self.width.hash(state);
Expand Down Expand Up @@ -243,7 +244,7 @@ pub trait Renderer: crate::Renderer {
impl<'a, Message, Renderer> From<Container<'a, Message, Renderer>>
for Element<'a, Message, Renderer>
where
Renderer: 'static + self::Renderer,
Renderer: 'a + self::Renderer,
Message: 'a,
{
fn from(
Expand Down
3 changes: 2 additions & 1 deletion native/src/widget/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ where
}

fn hash_layout(&self, state: &mut Hasher) {
std::any::TypeId::of::<Image>().hash(state);
struct Marker;
std::any::TypeId::of::<Marker>().hash(state);

self.handle.hash(state);
self.width.hash(state);
Expand Down
7 changes: 4 additions & 3 deletions native/src/widget/pane_grid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ pub struct KeyPressEvent {
impl<'a, Message, Renderer> Widget<Message, Renderer>
for PaneGrid<'a, Message, Renderer>
where
Renderer: 'static + self::Renderer,
Renderer: self::Renderer,
{
fn width(&self) -> Length {
self.width
Expand Down Expand Up @@ -597,8 +597,9 @@ where

fn hash_layout(&self, state: &mut Hasher) {
use std::hash::Hash;
struct Marker;
std::any::TypeId::of::<Marker>().hash(state);

std::any::TypeId::of::<PaneGrid<'_, (), Renderer>>().hash(state);
self.width.hash(state);
self.height.hash(state);
self.state.hash_layout(state);
Expand Down Expand Up @@ -643,7 +644,7 @@ pub trait Renderer: crate::Renderer + Sized {
impl<'a, Message, Renderer> From<PaneGrid<'a, Message, Renderer>>
for Element<'a, Message, Renderer>
where
Renderer: 'static + self::Renderer,
Renderer: 'a + self::Renderer,
Message: 'a,
{
fn from(
Expand Down
7 changes: 4 additions & 3 deletions native/src/widget/progress_bar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ impl<Renderer: self::Renderer> ProgressBar<Renderer> {

impl<Message, Renderer> Widget<Message, Renderer> for ProgressBar<Renderer>
where
Renderer: 'static + self::Renderer,
Renderer: self::Renderer,
{
fn width(&self) -> Length {
self.width
Expand Down Expand Up @@ -114,7 +114,8 @@ where
}

fn hash_layout(&self, state: &mut Hasher) {
std::any::TypeId::of::<ProgressBar<Renderer>>().hash(state);
struct Marker;
std::any::TypeId::of::<Marker>().hash(state);

self.width.hash(state);
self.height.hash(state);
Expand Down Expand Up @@ -159,7 +160,7 @@ pub trait Renderer: crate::Renderer {
impl<'a, Message, Renderer> From<ProgressBar<Renderer>>
for Element<'a, Message, Renderer>
where
Renderer: 'static + self::Renderer,
Renderer: 'a + self::Renderer,
Message: 'a,
{
fn from(
Expand Down
7 changes: 4 additions & 3 deletions native/src/widget/radio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ impl<Message, Renderer: self::Renderer> Radio<Message, Renderer> {

impl<Message, Renderer> Widget<Message, Renderer> for Radio<Message, Renderer>
where
Renderer: 'static + self::Renderer + text::Renderer + row::Renderer,
Renderer: self::Renderer + text::Renderer + row::Renderer,
Message: Clone,
{
fn width(&self) -> Length {
Expand Down Expand Up @@ -174,7 +174,8 @@ where
}

fn hash_layout(&self, state: &mut Hasher) {
std::any::TypeId::of::<Radio<(), Renderer>>().hash(state);
struct Marker;
std::any::TypeId::of::<Marker>().hash(state);

self.label.hash(state);
}
Expand Down Expand Up @@ -218,7 +219,7 @@ pub trait Renderer: crate::Renderer {
impl<'a, Message, Renderer> From<Radio<Message, Renderer>>
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<Message, Renderer>) -> Element<'a, Message, Renderer> {
Expand Down
7 changes: 4 additions & 3 deletions native/src/widget/row.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ impl<'a, Message, Renderer> Row<'a, Message, Renderer> {
impl<'a, Message, Renderer> Widget<Message, Renderer>
for Row<'a, Message, Renderer>
where
Renderer: 'static + self::Renderer,
Renderer: self::Renderer,
{
fn width(&self) -> Length {
self.width
Expand Down Expand Up @@ -191,7 +191,8 @@ where
}

fn hash_layout(&self, state: &mut Hasher) {
std::any::TypeId::of::<Row<'_, (), Renderer>>().hash(state);
struct Marker;
std::any::TypeId::of::<Marker>().hash(state);

self.width.hash(state);
self.height.hash(state);
Expand Down Expand Up @@ -236,7 +237,7 @@ pub trait Renderer: crate::Renderer + Sized {
impl<'a, Message, Renderer> From<Row<'a, Message, Renderer>>
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> {
Expand Down
7 changes: 4 additions & 3 deletions native/src/widget/scrollable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ impl<'a, Message, Renderer: self::Renderer> Scrollable<'a, Message, Renderer> {
impl<'a, Message, Renderer> Widget<Message, Renderer>
for Scrollable<'a, Message, Renderer>
where
Renderer: 'static + self::Renderer + column::Renderer,
Renderer: self::Renderer + column::Renderer,
{
fn width(&self) -> Length {
Widget::<Message, Renderer>::width(&self.content)
Expand Down Expand Up @@ -311,7 +311,8 @@ where
}

fn hash_layout(&self, state: &mut Hasher) {
std::any::TypeId::of::<Scrollable<'_, (), Renderer>>().hash(state);
struct Marker;
std::any::TypeId::of::<Marker>().hash(state);

self.height.hash(state);
self.max_height.hash(state);
Expand Down Expand Up @@ -505,7 +506,7 @@ pub trait Renderer: crate::Renderer + Sized {
impl<'a, Message, Renderer> From<Scrollable<'a, Message, Renderer>>
for Element<'a, Message, Renderer>
where
Renderer: 'static + self::Renderer + column::Renderer,
Renderer: 'a + self::Renderer + column::Renderer,
Message: 'a,
{
fn from(
Expand Down
7 changes: 4 additions & 3 deletions native/src/widget/slider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ impl State {
impl<'a, Message, Renderer> Widget<Message, Renderer>
for Slider<'a, Message, Renderer>
where
Renderer: 'static + self::Renderer,
Renderer: self::Renderer,
{
fn width(&self) -> Length {
self.width
Expand Down Expand Up @@ -205,7 +205,8 @@ where
}

fn hash_layout(&self, state: &mut Hasher) {
std::any::TypeId::of::<Slider<'_, (), Renderer>>().hash(state);
struct Marker;
std::any::TypeId::of::<Marker>().hash(state);

self.width.hash(state);
}
Expand Down Expand Up @@ -253,7 +254,7 @@ pub trait Renderer: crate::Renderer {
impl<'a, Message, Renderer> From<Slider<'a, Message, Renderer>>
for Element<'a, Message, Renderer>
where
Renderer: 'static + self::Renderer,
Renderer: 'a + self::Renderer,
Message: 'a,
{
fn from(
Expand Down
8 changes: 4 additions & 4 deletions native/src/widget/text_input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ impl<'a, Message, Renderer: self::Renderer> TextInput<'a, Message, Renderer> {
impl<'a, Message, Renderer> Widget<Message, Renderer>
for TextInput<'a, Message, Renderer>
where
Renderer: 'static + self::Renderer,
Renderer: self::Renderer,
Message: Clone,
{
fn width(&self) -> Length {
Expand Down Expand Up @@ -526,8 +526,8 @@ where

fn hash_layout(&self, state: &mut Hasher) {
use std::{any::TypeId, hash::Hash};

TypeId::of::<TextInput<'_, (), Renderer>>().hash(state);
struct Marker;
TypeId::of::<Marker>().hash(state);

self.width.hash(state);
self.max_width.hash(state);
Expand Down Expand Up @@ -632,7 +632,7 @@ pub trait Renderer: crate::Renderer + Sized {
impl<'a, Message, Renderer> From<TextInput<'a, Message, Renderer>>
for Element<'a, Message, Renderer>
where
Renderer: 'static + self::Renderer,
Renderer: 'a + self::Renderer,
Message: 'a + Clone,
{
fn from(
Expand Down