summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Ashley Wulber <ashley@system76.com>2022-09-10 22:15:25 -0400
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2022-11-03 03:23:36 +0100
commit4f3215f48e72ed36cb77efcb746db1f6adabf84f (patch)
tree34ecc6818fcbaad06f434bb7da6cbeec549c06b9
parentd5a933b047a955158a31a35266bbc9b25307b0fc (diff)
downloadiced-4f3215f48e72ed36cb77efcb746db1f6adabf84f.tar.gz
iced-4f3215f48e72ed36cb77efcb746db1f6adabf84f.tar.bz2
iced-4f3215f48e72ed36cb77efcb746db1f6adabf84f.zip
fix: clippy lint https://rust-lang.github.io/rust-clippy/master/index.html#large_enum_variant
-rw-r--r--examples/scrollable/src/main.rs2
-rw-r--r--examples/styling/src/main.rs9
-rw-r--r--style/src/theme.rs10
3 files changed, 12 insertions, 9 deletions
diff --git a/examples/scrollable/src/main.rs b/examples/scrollable/src/main.rs
index f0cd60f4..d5cf19cc 100644
--- a/examples/scrollable/src/main.rs
+++ b/examples/scrollable/src/main.rs
@@ -207,7 +207,7 @@ impl Application for ScrollableDemo {
}
fn theme(&self) -> Theme {
- self.theme
+ self.theme.clone()
}
}
diff --git a/examples/styling/src/main.rs b/examples/styling/src/main.rs
index 625a2b9a..784ea581 100644
--- a/examples/styling/src/main.rs
+++ b/examples/styling/src/main.rs
@@ -53,7 +53,10 @@ impl Sandbox for Styling {
};
let extended = Extended::generate(palette);
Styling {
- custom_theme: Theme::Custom { palette, extended },
+ custom_theme: Theme::Custom {
+ palette: Box::new(palette),
+ extended: Box::new(extended)
+ },
..Default::default()
}
}
@@ -67,7 +70,7 @@ impl Sandbox for Styling {
Message::ThemeChanged(theme) => self.theme = match theme {
ThemeType::Light => Theme::Light,
ThemeType::Dark => Theme::Dark,
- ThemeType::Custom => self.custom_theme,
+ ThemeType::Custom => self.custom_theme.clone(),
},
Message::InputChanged(value) => self.input_value = value,
Message::ButtonPressed => {}
@@ -163,6 +166,6 @@ impl Sandbox for Styling {
}
fn theme(&self) -> Theme {
- self.theme
+ self.theme.clone()
}
}
diff --git a/style/src/theme.rs b/style/src/theme.rs
index 7d47f1a1..4e83758b 100644
--- a/style/src/theme.rs
+++ b/style/src/theme.rs
@@ -21,13 +21,13 @@ use crate::toggler;
use iced_core::{Background, Color};
-#[derive(Debug, Clone, Copy, PartialEq)]
+#[derive(Debug, Clone, PartialEq)]
pub enum Theme {
Light,
Dark,
Custom {
- palette: Palette,
- extended: Extended
+ palette: Box<Palette>,
+ extended: Box<Extended>,
}
}
@@ -36,7 +36,7 @@ impl Theme {
match self {
Self::Light => Palette::LIGHT,
Self::Dark => Palette::DARK,
- Self::Custom { palette, .. } => palette
+ Self::Custom { palette, .. } => *palette
}
}
@@ -78,7 +78,7 @@ impl application::StyleSheet for Theme {
background_color: palette.background.base.color,
text_color: palette.background.base.text,
},
- Application::Custom(f) => f(*self),
+ Application::Custom(f) => f(self.clone()),
}
}
}