From 1f46fd871b04ba738e3817d03131bf5ce46f5e46 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Thu, 7 Mar 2024 21:13:23 +0100 Subject: Fix consistency of `with_background` for `button::Appearance` --- widget/src/button.rs | 10 +++++----- 1 file 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) -> Self { + /// Updates the [`Appearance`] with the given [`Background`]. + pub fn with_background(self, background: impl Into) -> 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 { - |color, _status| Appearance::with_background(*color) + |color, _status| Appearance::default().with_background(*color) } } -- cgit