diff options
author | 2021-11-07 15:15:33 +0700 | |
---|---|---|
committer | 2021-11-07 15:15:33 +0700 | |
commit | eafad00af2a9bae9f3ed8124e2a6f6e59ee5d253 (patch) | |
tree | 76413948c9c9723075189d51d4c2e02c0f8fdd23 /web/src/widget/checkbox.rs | |
parent | 61c747b53589d98f477fea95f85d2ea5349666d3 (diff) | |
parent | 07b5097bc92ced376d09115d787ff1d2ebe00836 (diff) | |
download | iced-eafad00af2a9bae9f3ed8124e2a6f6e59ee5d253.tar.gz iced-eafad00af2a9bae9f3ed8124e2a6f6e59ee5d253.tar.bz2 iced-eafad00af2a9bae9f3ed8124e2a6f6e59ee5d253.zip |
Merge pull request #1110 from iced-rs/remove-renderer-traits
Reduce the surface of the `Renderer` APIs
Diffstat (limited to 'web/src/widget/checkbox.rs')
-rw-r--r-- | web/src/widget/checkbox.rs | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/web/src/widget/checkbox.rs b/web/src/widget/checkbox.rs index 43110aa7..844bf862 100644 --- a/web/src/widget/checkbox.rs +++ b/web/src/widget/checkbox.rs @@ -24,17 +24,17 @@ use std::rc::Rc; /// ///  #[allow(missing_debug_implementations)] -pub struct Checkbox<Message> { +pub struct Checkbox<'a, Message> { is_checked: bool, on_toggle: Rc<dyn Fn(bool) -> Message>, label: String, id: Option<String>, width: Length, #[allow(dead_code)] - style: Box<dyn StyleSheet>, + style_sheet: Box<dyn StyleSheet + 'a>, } -impl<Message> Checkbox<Message> { +impl<'a, Message> Checkbox<'a, Message> { /// Creates a new [`Checkbox`]. /// /// It expects: @@ -53,7 +53,7 @@ impl<Message> Checkbox<Message> { label: label.into(), id: None, width: Length::Shrink, - style: Default::default(), + style_sheet: Default::default(), } } @@ -64,8 +64,11 @@ impl<Message> Checkbox<Message> { } /// Sets the style of the [`Checkbox`]. - pub fn style(mut self, style: impl Into<Box<dyn StyleSheet>>) -> Self { - self.style = style.into(); + pub fn style( + mut self, + style_sheet: impl Into<Box<dyn StyleSheet + 'a>>, + ) -> Self { + self.style_sheet = style_sheet.into(); self } @@ -76,7 +79,7 @@ impl<Message> Checkbox<Message> { } } -impl<Message> Widget<Message> for Checkbox<Message> +impl<'a, Message> Widget<Message> for Checkbox<'a, Message> where Message: 'static, { @@ -137,11 +140,11 @@ where } } -impl<'a, Message> From<Checkbox<Message>> for Element<'a, Message> +impl<'a, Message> From<Checkbox<'a, Message>> for Element<'a, Message> where Message: 'static, { - fn from(checkbox: Checkbox<Message>) -> Element<'a, Message> { + fn from(checkbox: Checkbox<'a, Message>) -> Element<'a, Message> { Element::new(checkbox) } } |