diff --git a/examples/color_palette/src/main.rs b/examples/color_palette/src/main.rs index fec5f48c..bb2c61cb 100644 --- a/examples/color_palette/src/main.rs +++ b/examples/color_palette/src/main.rs @@ -284,7 +284,7 @@ impl ColorPicker { let [s1, s2, s3] = &mut self.sliders; let [cr1, cr2, cr3] = C::COMPONENT_RANGES; - fn slider( + fn slider( state: &mut slider::State, range: RangeInclusive, component: f32, diff --git a/examples/tour/src/main.rs b/examples/tour/src/main.rs index ec464801..560d67e2 100644 --- a/examples/tour/src/main.rs +++ b/examples/tour/src/main.rs @@ -689,7 +689,7 @@ fn ferris<'a>(width: u16) -> Container<'a, StepMessage> { .center_x() } -fn button<'a, Message>( +fn button<'a, Message: Clone>( state: &'a mut button::State, label: &str, ) -> Button<'a, Message> { diff --git a/native/src/widget/button.rs b/native/src/widget/button.rs index c932da2b..fd74563a 100644 --- a/native/src/widget/button.rs +++ b/native/src/widget/button.rs @@ -18,6 +18,7 @@ use std::hash::Hash; /// # type Button<'a, Message> = /// # iced_native::Button<'a, Message, iced_native::renderer::Null>; /// # +/// #[derive(Clone)] /// enum Message { /// ButtonPressed, /// } @@ -41,6 +42,7 @@ pub struct Button<'a, Message, Renderer: self::Renderer> { impl<'a, Message, Renderer> Button<'a, Message, Renderer> where + Message: Clone, Renderer: self::Renderer, { /// Creates a new [`Button`] with some local [`State`] and the given @@ -142,8 +144,8 @@ impl State { impl<'a, Message, Renderer> Widget for Button<'a, Message, Renderer> where - Renderer: self::Renderer, Message: Clone, + Renderer: self::Renderer, { fn width(&self) -> Length { self.width @@ -272,8 +274,8 @@ pub trait Renderer: crate::Renderer + Sized { impl<'a, Message, Renderer> From> for Element<'a, Message, Renderer> where - Renderer: 'a + self::Renderer, Message: 'a + Clone, + Renderer: 'a + self::Renderer, { fn from( button: Button<'a, Message, Renderer>, diff --git a/native/src/widget/radio.rs b/native/src/widget/radio.rs index 5b8d00e9..a7cabd49 100644 --- a/native/src/widget/radio.rs +++ b/native/src/widget/radio.rs @@ -47,6 +47,8 @@ pub struct Radio { impl Radio +where + Message: Clone, { /// Creates a new [`Radio`] button. /// @@ -123,8 +125,8 @@ impl impl Widget for Radio where - Renderer: self::Renderer + text::Renderer + row::Renderer, Message: Clone, + Renderer: self::Renderer + text::Renderer + row::Renderer, { fn width(&self) -> Length { self.width @@ -264,8 +266,8 @@ pub trait Renderer: crate::Renderer { impl<'a, Message, Renderer> From> for Element<'a, Message, Renderer> where - Renderer: 'a + self::Renderer + row::Renderer + text::Renderer, Message: 'a + Clone, + Renderer: 'a + self::Renderer + row::Renderer + text::Renderer, { fn from(radio: Radio) -> Element<'a, Message, Renderer> { Element::new(radio) diff --git a/native/src/widget/slider.rs b/native/src/widget/slider.rs index c49053f1..3255dd04 100644 --- a/native/src/widget/slider.rs +++ b/native/src/widget/slider.rs @@ -26,6 +26,7 @@ use std::{hash::Hash, ops::RangeInclusive}; /// # use iced_native::{slider, renderer::Null}; /// # /// # pub type Slider<'a, T, Message> = iced_native::Slider<'a, T, Message, Null>; +/// #[derive(Clone)] /// pub enum Message { /// SliderChanged(f32), /// } @@ -53,6 +54,7 @@ pub struct Slider<'a, T, Message, Renderer: self::Renderer> { impl<'a, T, Message, Renderer> Slider<'a, T, Message, Renderer> where T: Copy + From + std::cmp::PartialOrd, + Message: Clone, Renderer: self::Renderer, { /// Creates a new [`Slider`]. @@ -168,8 +170,8 @@ impl<'a, T, Message, Renderer> Widget for Slider<'a, T, Message, Renderer> where T: Copy + Into + num_traits::FromPrimitive, - Renderer: self::Renderer, Message: Clone, + Renderer: self::Renderer, { fn width(&self) -> Length { self.width @@ -322,8 +324,8 @@ impl<'a, T, Message, Renderer> From> for Element<'a, Message, Renderer> where T: 'a + Copy + Into + num_traits::FromPrimitive, - Renderer: 'a + self::Renderer, Message: 'a + Clone, + Renderer: 'a + self::Renderer, { fn from( slider: Slider<'a, T, Message, Renderer>, diff --git a/native/src/widget/text_input.rs b/native/src/widget/text_input.rs index 9e15f4be..32a57ce6 100644 --- a/native/src/widget/text_input.rs +++ b/native/src/widget/text_input.rs @@ -63,7 +63,11 @@ pub struct TextInput<'a, Message, Renderer: self::Renderer> { style: Renderer::Style, } -impl<'a, Message, Renderer: self::Renderer> TextInput<'a, Message, Renderer> { +impl<'a, Message, Renderer> TextInput<'a, Message, Renderer> +where + Message: Clone, + Renderer: self::Renderer, +{ /// Creates a new [`TextInput`]. /// /// It expects: @@ -175,8 +179,8 @@ impl<'a, Message, Renderer: self::Renderer> TextInput<'a, Message, Renderer> { impl<'a, Message, Renderer> Widget for TextInput<'a, Message, Renderer> where - Renderer: self::Renderer, Message: Clone, + Renderer: self::Renderer, { fn width(&self) -> Length { self.width @@ -629,8 +633,8 @@ pub trait Renderer: text::Renderer + Sized { impl<'a, Message, Renderer> From> for Element<'a, Message, Renderer> where - Renderer: 'a + self::Renderer, Message: 'a + Clone, + Renderer: 'a + self::Renderer, { fn from( text_input: TextInput<'a, Message, Renderer>,