diff options
author | 2024-03-07 21:13:23 +0100 | |
---|---|---|
committer | 2024-03-07 21:13:23 +0100 | |
commit | 1f46fd871b04ba738e3817d03131bf5ce46f5e46 (patch) | |
tree | 5f1b20a695c9a591627fb4e70b091b183ce43862 /widget/src | |
parent | 7ece5eea509f3595432babfc7729701f2e063b21 (diff) | |
download | iced-1f46fd871b04ba738e3817d03131bf5ce46f5e46.tar.gz iced-1f46fd871b04ba738e3817d03131bf5ce46f5e46.tar.bz2 iced-1f46fd871b04ba738e3817d03131bf5ce46f5e46.zip |
Fix consistency of `with_background` for `button::Appearance`
Diffstat (limited to 'widget/src')
-rw-r--r-- | widget/src/button.rs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/widget/src/button.rs b/widget/src/button.rs index 9ce856bb..4563f3f4 100644 --- a/widget/src/button.rs +++ b/widget/src/button.rs @@ -397,7 +397,7 @@ pub enum Status { } /// The appearance of a button. -#[derive(Debug, Clone, Copy)] +#[derive(Debug, Clone, Copy, PartialEq)] pub struct Appearance { /// The amount of offset to apply to the shadow of the button. pub shadow_offset: Vector, @@ -412,11 +412,11 @@ pub struct Appearance { } impl Appearance { - /// Creates an [`Appearance`] with the given [`Background`]. - pub fn with_background(background: impl Into<Background>) -> Self { + /// Updates the [`Appearance`] with the given [`Background`]. + pub fn with_background(self, background: impl Into<Background>) -> Self { Self { background: Some(background.into()), - ..Self::default() + ..self } } } @@ -456,7 +456,7 @@ impl DefaultStyle for Appearance { impl DefaultStyle for Color { fn default_style() -> Style<Self> { - |color, _status| Appearance::with_background(*color) + |color, _status| Appearance::default().with_background(*color) } } |