Merge pull request #245 from tirz/refactor-bound_lifetime
refactor: remove not mandatories 'static lifetimes
This commit is contained in:
commit
6e9ab1cd6f
@ -37,16 +37,16 @@ members = [
|
||||
"web",
|
||||
"wgpu",
|
||||
"winit",
|
||||
"examples/download_progress",
|
||||
"examples/bezier_tool",
|
||||
"examples/clock",
|
||||
"examples/counter",
|
||||
"examples/custom_widget",
|
||||
"examples/download_progress",
|
||||
"examples/events",
|
||||
"examples/geometry",
|
||||
"examples/integration",
|
||||
"examples/pokedex",
|
||||
"examples/pane_grid",
|
||||
"examples/pokedex",
|
||||
"examples/progress_bar",
|
||||
"examples/solar_system",
|
||||
"examples/stopwatch",
|
||||
|
@ -143,7 +143,7 @@ impl State {
|
||||
impl<'a, Message, Renderer> Widget<Message, Renderer>
|
||||
for Button<'a, Message, Renderer>
|
||||
where
|
||||
Renderer: self::Renderer,
|
||||
Renderer: 'static + self::Renderer,
|
||||
Message: Clone,
|
||||
{
|
||||
fn width(&self) -> Length {
|
||||
@ -234,6 +234,8 @@ where
|
||||
}
|
||||
|
||||
fn hash_layout(&self, state: &mut Hasher) {
|
||||
std::any::TypeId::of::<Button<'_, (), Renderer>>().hash(state);
|
||||
|
||||
self.width.hash(state);
|
||||
self.content.hash_layout(state);
|
||||
}
|
||||
@ -275,7 +277,7 @@ impl<'a, Message, Renderer> From<Button<'a, Message, Renderer>>
|
||||
for Element<'a, Message, Renderer>
|
||||
where
|
||||
Renderer: 'static + self::Renderer,
|
||||
Message: 'static + Clone,
|
||||
Message: 'a + Clone,
|
||||
{
|
||||
fn from(
|
||||
button: Button<'a, Message, Renderer>,
|
||||
|
@ -110,7 +110,7 @@ impl<Message, Renderer: self::Renderer + text::Renderer>
|
||||
impl<Message, Renderer> Widget<Message, Renderer>
|
||||
for Checkbox<Message, Renderer>
|
||||
where
|
||||
Renderer: self::Renderer + text::Renderer + row::Renderer,
|
||||
Renderer: 'static + self::Renderer + text::Renderer + row::Renderer,
|
||||
{
|
||||
fn width(&self) -> Length {
|
||||
self.width
|
||||
@ -205,6 +205,8 @@ where
|
||||
}
|
||||
|
||||
fn hash_layout(&self, state: &mut Hasher) {
|
||||
std::any::TypeId::of::<Checkbox<(), Renderer>>().hash(state);
|
||||
|
||||
self.label.hash(state);
|
||||
}
|
||||
}
|
||||
@ -253,7 +255,7 @@ impl<'a, Message, Renderer> From<Checkbox<Message, Renderer>>
|
||||
for Element<'a, Message, Renderer>
|
||||
where
|
||||
Renderer: 'static + self::Renderer + text::Renderer + row::Renderer,
|
||||
Message: 'static,
|
||||
Message: 'a,
|
||||
{
|
||||
fn from(
|
||||
checkbox: Checkbox<Message, Renderer>,
|
||||
|
@ -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: self::Renderer,
|
||||
Renderer: 'static + self::Renderer,
|
||||
{
|
||||
fn width(&self) -> Length {
|
||||
self.width
|
||||
@ -190,7 +190,8 @@ where
|
||||
}
|
||||
|
||||
fn hash_layout(&self, state: &mut Hasher) {
|
||||
0.hash(state);
|
||||
std::any::TypeId::of::<Column<'_, (), Renderer>>().hash(state);
|
||||
|
||||
self.width.hash(state);
|
||||
self.height.hash(state);
|
||||
self.max_width.hash(state);
|
||||
@ -233,8 +234,8 @@ pub trait Renderer: crate::Renderer + Sized {
|
||||
impl<'a, Message, Renderer> From<Column<'a, Message, Renderer>>
|
||||
for Element<'a, Message, Renderer>
|
||||
where
|
||||
Renderer: 'a + self::Renderer,
|
||||
Message: 'static,
|
||||
Renderer: 'static + self::Renderer,
|
||||
Message: 'a,
|
||||
{
|
||||
fn from(
|
||||
column: Column<'a, Message, Renderer>,
|
||||
|
@ -122,7 +122,7 @@ where
|
||||
impl<'a, Message, Renderer> Widget<Message, Renderer>
|
||||
for Container<'a, Message, Renderer>
|
||||
where
|
||||
Renderer: self::Renderer,
|
||||
Renderer: 'static + self::Renderer,
|
||||
{
|
||||
fn width(&self) -> Length {
|
||||
self.width
|
||||
@ -189,7 +189,8 @@ where
|
||||
}
|
||||
|
||||
fn hash_layout(&self, state: &mut Hasher) {
|
||||
0.hash(state);
|
||||
std::any::TypeId::of::<Container<'_, (), Renderer>>().hash(state);
|
||||
|
||||
self.width.hash(state);
|
||||
self.height.hash(state);
|
||||
self.max_width.hash(state);
|
||||
@ -227,8 +228,8 @@ pub trait Renderer: crate::Renderer {
|
||||
impl<'a, Message, Renderer> From<Container<'a, Message, Renderer>>
|
||||
for Element<'a, Message, Renderer>
|
||||
where
|
||||
Renderer: 'a + self::Renderer,
|
||||
Message: 'static,
|
||||
Renderer: 'static + self::Renderer,
|
||||
Message: 'a,
|
||||
{
|
||||
fn from(
|
||||
column: Container<'a, Message, Renderer>,
|
||||
|
@ -102,6 +102,8 @@ where
|
||||
}
|
||||
|
||||
fn hash_layout(&self, state: &mut Hasher) {
|
||||
std::any::TypeId::of::<Image>().hash(state);
|
||||
|
||||
self.handle.hash(state);
|
||||
self.width.hash(state);
|
||||
self.height.hash(state);
|
||||
|
@ -80,9 +80,9 @@ pub struct PaneGrid<'a, Message, Renderer> {
|
||||
height: Length,
|
||||
spacing: u16,
|
||||
modifier_keys: keyboard::ModifiersState,
|
||||
on_drag: Option<Box<dyn Fn(DragEvent) -> Message>>,
|
||||
on_resize: Option<Box<dyn Fn(ResizeEvent) -> Message>>,
|
||||
on_key_press: Option<Box<dyn Fn(KeyPressEvent) -> Option<Message>>>,
|
||||
on_drag: Option<Box<dyn Fn(DragEvent) -> Message + 'a>>,
|
||||
on_resize: Option<Box<dyn Fn(ResizeEvent) -> Message + 'a>>,
|
||||
on_key_press: Option<Box<dyn Fn(KeyPressEvent) -> Option<Message> + 'a>>,
|
||||
}
|
||||
|
||||
impl<'a, Message, Renderer> PaneGrid<'a, Message, Renderer> {
|
||||
@ -187,10 +187,10 @@ impl<'a, Message, Renderer> PaneGrid<'a, Message, Renderer> {
|
||||
/// Panes can be dragged using `Modifier keys + Left click`.
|
||||
///
|
||||
/// [`PaneGrid`]: struct.PaneGrid.html
|
||||
pub fn on_drag(
|
||||
mut self,
|
||||
f: impl Fn(DragEvent) -> Message + 'static,
|
||||
) -> Self {
|
||||
pub fn on_drag<F>(mut self, f: F) -> Self
|
||||
where
|
||||
F: 'a + Fn(DragEvent) -> Message,
|
||||
{
|
||||
self.on_drag = Some(Box::new(f));
|
||||
self
|
||||
}
|
||||
@ -201,10 +201,10 @@ impl<'a, Message, Renderer> PaneGrid<'a, Message, Renderer> {
|
||||
/// Panes can be resized using `Modifier keys + Right click`.
|
||||
///
|
||||
/// [`PaneGrid`]: struct.PaneGrid.html
|
||||
pub fn on_resize(
|
||||
mut self,
|
||||
f: impl Fn(ResizeEvent) -> Message + 'static,
|
||||
) -> Self {
|
||||
pub fn on_resize<F>(mut self, f: F) -> Self
|
||||
where
|
||||
F: 'a + Fn(ResizeEvent) -> Message,
|
||||
{
|
||||
self.on_resize = Some(Box::new(f));
|
||||
self
|
||||
}
|
||||
@ -226,10 +226,10 @@ impl<'a, Message, Renderer> PaneGrid<'a, Message, Renderer> {
|
||||
///
|
||||
/// [`PaneGrid`]: struct.PaneGrid.html
|
||||
/// [`Pane`]: struct.Pane.html
|
||||
pub fn on_key_press(
|
||||
mut self,
|
||||
f: impl Fn(KeyPressEvent) -> Option<Message> + 'static,
|
||||
) -> Self {
|
||||
pub fn on_key_press<F>(mut self, f: F) -> Self
|
||||
where
|
||||
F: 'a + Fn(KeyPressEvent) -> Option<Message>,
|
||||
{
|
||||
self.on_key_press = Some(Box::new(f));
|
||||
self
|
||||
}
|
||||
@ -348,8 +348,7 @@ pub struct KeyPressEvent {
|
||||
impl<'a, Message, Renderer> Widget<Message, Renderer>
|
||||
for PaneGrid<'a, Message, Renderer>
|
||||
where
|
||||
Renderer: self::Renderer + 'static,
|
||||
Message: 'static,
|
||||
Renderer: 'static + self::Renderer,
|
||||
{
|
||||
fn width(&self) -> Length {
|
||||
self.width
|
||||
@ -591,7 +590,7 @@ where
|
||||
fn hash_layout(&self, state: &mut Hasher) {
|
||||
use std::hash::Hash;
|
||||
|
||||
std::any::TypeId::of::<PaneGrid<'_, Message, Renderer>>().hash(state);
|
||||
std::any::TypeId::of::<PaneGrid<'_, (), Renderer>>().hash(state);
|
||||
self.width.hash(state);
|
||||
self.height.hash(state);
|
||||
self.state.hash_layout(state);
|
||||
@ -636,8 +635,8 @@ pub trait Renderer: crate::Renderer + Sized {
|
||||
impl<'a, Message, Renderer> From<PaneGrid<'a, Message, Renderer>>
|
||||
for Element<'a, Message, Renderer>
|
||||
where
|
||||
Renderer: self::Renderer + 'static,
|
||||
Message: 'static,
|
||||
Renderer: 'static + self::Renderer,
|
||||
Message: 'a,
|
||||
{
|
||||
fn from(
|
||||
pane_grid: PaneGrid<'a, Message, Renderer>,
|
||||
|
@ -72,7 +72,7 @@ impl<Renderer: self::Renderer> ProgressBar<Renderer> {
|
||||
|
||||
impl<Message, Renderer> Widget<Message, Renderer> for ProgressBar<Renderer>
|
||||
where
|
||||
Renderer: self::Renderer,
|
||||
Renderer: 'static + self::Renderer,
|
||||
{
|
||||
fn width(&self) -> Length {
|
||||
self.width
|
||||
@ -114,6 +114,8 @@ where
|
||||
}
|
||||
|
||||
fn hash_layout(&self, state: &mut Hasher) {
|
||||
std::any::TypeId::of::<ProgressBar<Renderer>>().hash(state);
|
||||
|
||||
self.width.hash(state);
|
||||
self.height.hash(state);
|
||||
}
|
||||
@ -158,7 +160,7 @@ impl<'a, Message, Renderer> From<ProgressBar<Renderer>>
|
||||
for Element<'a, Message, Renderer>
|
||||
where
|
||||
Renderer: 'static + self::Renderer,
|
||||
Message: 'static,
|
||||
Message: 'a,
|
||||
{
|
||||
fn from(
|
||||
progress_bar: ProgressBar<Renderer>,
|
||||
|
@ -77,7 +77,7 @@ impl<Message, Renderer: self::Renderer> Radio<Message, Renderer> {
|
||||
|
||||
impl<Message, Renderer> Widget<Message, Renderer> for Radio<Message, Renderer>
|
||||
where
|
||||
Renderer: self::Renderer + text::Renderer + row::Renderer,
|
||||
Renderer: 'static + self::Renderer + text::Renderer + row::Renderer,
|
||||
Message: Clone,
|
||||
{
|
||||
fn width(&self) -> Length {
|
||||
@ -169,6 +169,8 @@ where
|
||||
}
|
||||
|
||||
fn hash_layout(&self, state: &mut Hasher) {
|
||||
std::any::TypeId::of::<Radio<(), Renderer>>().hash(state);
|
||||
|
||||
self.label.hash(state);
|
||||
}
|
||||
}
|
||||
@ -212,7 +214,7 @@ impl<'a, Message, Renderer> From<Radio<Message, Renderer>>
|
||||
for Element<'a, Message, Renderer>
|
||||
where
|
||||
Renderer: 'static + self::Renderer + row::Renderer + text::Renderer,
|
||||
Message: 'static + Clone,
|
||||
Message: 'a + Clone,
|
||||
{
|
||||
fn from(radio: Radio<Message, Renderer>) -> Element<'a, Message, Renderer> {
|
||||
Element::new(radio)
|
||||
|
@ -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: self::Renderer,
|
||||
Renderer: 'static + self::Renderer,
|
||||
{
|
||||
fn width(&self) -> Length {
|
||||
self.width
|
||||
@ -191,7 +191,8 @@ where
|
||||
}
|
||||
|
||||
fn hash_layout(&self, state: &mut Hasher) {
|
||||
1.hash(state);
|
||||
std::any::TypeId::of::<Row<'_, (), Renderer>>().hash(state);
|
||||
|
||||
self.width.hash(state);
|
||||
self.height.hash(state);
|
||||
self.max_width.hash(state);
|
||||
@ -235,8 +236,8 @@ pub trait Renderer: crate::Renderer + Sized {
|
||||
impl<'a, Message, Renderer> From<Row<'a, Message, Renderer>>
|
||||
for Element<'a, Message, Renderer>
|
||||
where
|
||||
Renderer: 'a + self::Renderer,
|
||||
Message: 'static,
|
||||
Renderer: 'static + self::Renderer,
|
||||
Message: 'a,
|
||||
{
|
||||
fn from(row: Row<'a, Message, Renderer>) -> Element<'a, Message, Renderer> {
|
||||
Element::new(row)
|
||||
|
@ -311,7 +311,7 @@ where
|
||||
}
|
||||
|
||||
fn hash_layout(&self, state: &mut Hasher) {
|
||||
std::any::TypeId::of::<Scrollable<'static, (), Renderer>>().hash(state);
|
||||
std::any::TypeId::of::<Scrollable<'_, (), Renderer>>().hash(state);
|
||||
|
||||
self.height.hash(state);
|
||||
self.max_height.hash(state);
|
||||
@ -506,7 +506,7 @@ impl<'a, Message, Renderer> From<Scrollable<'a, Message, Renderer>>
|
||||
for Element<'a, Message, Renderer>
|
||||
where
|
||||
Renderer: 'static + self::Renderer + column::Renderer,
|
||||
Message: 'static,
|
||||
Message: 'a,
|
||||
{
|
||||
fn from(
|
||||
scrollable: Scrollable<'a, Message, Renderer>,
|
||||
|
@ -114,7 +114,7 @@ impl State {
|
||||
impl<'a, Message, Renderer> Widget<Message, Renderer>
|
||||
for Slider<'a, Message, Renderer>
|
||||
where
|
||||
Renderer: self::Renderer,
|
||||
Renderer: 'static + self::Renderer,
|
||||
{
|
||||
fn width(&self) -> Length {
|
||||
self.width
|
||||
@ -205,6 +205,8 @@ where
|
||||
}
|
||||
|
||||
fn hash_layout(&self, state: &mut Hasher) {
|
||||
std::any::TypeId::of::<Slider<'_, (), Renderer>>().hash(state);
|
||||
|
||||
self.width.hash(state);
|
||||
}
|
||||
}
|
||||
@ -252,7 +254,7 @@ impl<'a, Message, Renderer> From<Slider<'a, Message, Renderer>>
|
||||
for Element<'a, Message, Renderer>
|
||||
where
|
||||
Renderer: 'static + self::Renderer,
|
||||
Message: 'static,
|
||||
Message: 'a,
|
||||
{
|
||||
fn from(
|
||||
slider: Slider<'a, Message, Renderer>,
|
||||
|
@ -77,6 +77,7 @@ where
|
||||
|
||||
fn hash_layout(&self, state: &mut Hasher) {
|
||||
std::any::TypeId::of::<Space>().hash(state);
|
||||
|
||||
self.width.hash(state);
|
||||
self.height.hash(state);
|
||||
}
|
||||
@ -97,7 +98,7 @@ pub trait Renderer: crate::Renderer {
|
||||
impl<'a, Message, Renderer> From<Space> for Element<'a, Message, Renderer>
|
||||
where
|
||||
Renderer: self::Renderer,
|
||||
Message: 'static,
|
||||
Message: 'a,
|
||||
{
|
||||
fn from(space: Space) -> Element<'a, Message, Renderer> {
|
||||
Element::new(space)
|
||||
|
@ -99,6 +99,8 @@ where
|
||||
}
|
||||
|
||||
fn hash_layout(&self, state: &mut Hasher) {
|
||||
std::any::TypeId::of::<Svg>().hash(state);
|
||||
|
||||
self.width.hash(state);
|
||||
self.height.hash(state);
|
||||
}
|
||||
|
@ -163,6 +163,8 @@ where
|
||||
}
|
||||
|
||||
fn hash_layout(&self, state: &mut Hasher) {
|
||||
std::any::TypeId::of::<Text>().hash(state);
|
||||
|
||||
self.content.hash(state);
|
||||
self.size.hash(state);
|
||||
self.width.hash(state);
|
||||
|
@ -172,7 +172,7 @@ impl<'a, Message, Renderer> Widget<Message, Renderer>
|
||||
for TextInput<'a, Message, Renderer>
|
||||
where
|
||||
Renderer: 'static + self::Renderer,
|
||||
Message: Clone + std::fmt::Debug,
|
||||
Message: Clone,
|
||||
{
|
||||
fn width(&self) -> Length {
|
||||
self.width
|
||||
@ -501,7 +501,7 @@ where
|
||||
fn hash_layout(&self, state: &mut Hasher) {
|
||||
use std::{any::TypeId, hash::Hash};
|
||||
|
||||
TypeId::of::<TextInput<'static, (), Renderer>>().hash(state);
|
||||
TypeId::of::<TextInput<'_, (), Renderer>>().hash(state);
|
||||
|
||||
self.width.hash(state);
|
||||
self.max_width.hash(state);
|
||||
@ -607,7 +607,7 @@ impl<'a, Message, Renderer> From<TextInput<'a, Message, Renderer>>
|
||||
for Element<'a, Message, Renderer>
|
||||
where
|
||||
Renderer: 'static + self::Renderer,
|
||||
Message: 'static + Clone + std::fmt::Debug,
|
||||
Message: 'a + Clone,
|
||||
{
|
||||
fn from(
|
||||
text_input: TextInput<'a, Message, Renderer>,
|
||||
|
Loading…
Reference in New Issue
Block a user