refactor: remove not mandatory static lifetime

This commit is contained in:
Théo Gaillard 2020-03-30 06:30:22 +08:00
parent 5b2c71a708
commit 0539cd1b85
No known key found for this signature in database
GPG Key ID: 9C6AAAF893B070FC
13 changed files with 32 additions and 32 deletions

View File

@ -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",

View File

@ -274,8 +274,8 @@ 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,
Message: 'static + Clone,
Renderer: 'a + self::Renderer,
Message: 'a + Clone,
{
fn from(
button: Button<'a, Message, Renderer>,

View File

@ -252,8 +252,8 @@ 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,
Message: 'static,
Renderer: 'a + self::Renderer + text::Renderer + row::Renderer,
Message: 'a,
{
fn from(
checkbox: Checkbox<Message, Renderer>,

View File

@ -234,7 +234,7 @@ impl<'a, Message, Renderer> From<Column<'a, Message, Renderer>>
for Element<'a, Message, Renderer>
where
Renderer: 'a + self::Renderer,
Message: 'static,
Message: 'a,
{
fn from(
column: Column<'a, Message, Renderer>,

View File

@ -228,7 +228,7 @@ impl<'a, Message, Renderer> From<Container<'a, Message, Renderer>>
for Element<'a, Message, Renderer>
where
Renderer: 'a + self::Renderer,
Message: 'static,
Message: 'a,
{
fn from(
column: Container<'a, Message, Renderer>,

View File

@ -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: 'static + 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: 'static + 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: 'static + Fn(KeyPressEvent) -> Option<Message>,
{
self.on_key_press = Some(Box::new(f));
self
}
@ -348,7 +348,7 @@ pub struct KeyPressEvent {
impl<'a, Message, Renderer> Widget<Message, Renderer>
for PaneGrid<'a, Message, Renderer>
where
Renderer: self::Renderer + 'static,
Renderer: 'static + self::Renderer,
Message: 'static,
{
fn width(&self) -> Length {
@ -636,7 +636,7 @@ 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,
Renderer: 'static + self::Renderer,
Message: 'static,
{
fn from(

View File

@ -157,8 +157,8 @@ pub trait Renderer: crate::Renderer {
impl<'a, Message, Renderer> From<ProgressBar<Renderer>>
for Element<'a, Message, Renderer>
where
Renderer: 'static + self::Renderer,
Message: 'static,
Renderer: 'a + self::Renderer,
Message: 'a,
{
fn from(
progress_bar: ProgressBar<Renderer>,

View File

@ -211,8 +211,8 @@ 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,
Message: 'static + Clone,
Renderer: 'a + self::Renderer + row::Renderer + text::Renderer,
Message: 'a + Clone,
{
fn from(radio: Radio<Message, Renderer>) -> Element<'a, Message, Renderer> {
Element::new(radio)

View File

@ -236,7 +236,7 @@ impl<'a, Message, Renderer> From<Row<'a, Message, Renderer>>
for Element<'a, Message, Renderer>
where
Renderer: 'a + self::Renderer,
Message: 'static,
Message: 'a,
{
fn from(row: Row<'a, Message, Renderer>) -> Element<'a, Message, Renderer> {
Element::new(row)

View File

@ -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>,

View File

@ -251,8 +251,8 @@ pub trait Renderer: crate::Renderer {
impl<'a, Message, Renderer> From<Slider<'a, Message, Renderer>>
for Element<'a, Message, Renderer>
where
Renderer: 'static + self::Renderer,
Message: 'static,
Renderer: 'a + self::Renderer,
Message: 'a,
{
fn from(
slider: Slider<'a, Message, Renderer>,

View File

@ -97,7 +97,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)

View File

@ -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 + std::fmt::Debug,
{
fn from(
text_input: TextInput<'a, Message, Renderer>,