diff options
author | 2020-01-06 18:46:47 +0100 | |
---|---|---|
committer | 2020-01-06 18:46:47 +0100 | |
commit | fbc25f8d3d94be148663dbbe1de6ceb9c162b308 (patch) | |
tree | 832b24ebcbdb95a39f3192ca9c836be419e80f6c /examples | |
parent | 2bbd395d5dcdf9c92ffb354b8b05444478e4b344 (diff) | |
download | iced-fbc25f8d3d94be148663dbbe1de6ceb9c162b308.tar.gz iced-fbc25f8d3d94be148663dbbe1de6ceb9c162b308.tar.bz2 iced-fbc25f8d3d94be148663dbbe1de6ceb9c162b308.zip |
Implement `Default` for `Theme` in `styling` example
Diffstat (limited to 'examples')
-rw-r--r-- | examples/styling.rs | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/examples/styling.rs b/examples/styling.rs index 95590f2c..9f8cc53f 100644 --- a/examples/styling.rs +++ b/examples/styling.rs @@ -7,6 +7,7 @@ pub fn main() { Styling::run(Settings::default()) } +#[derive(Default)] struct Styling { theme: style::Theme, input: text_input::State, @@ -25,12 +26,7 @@ impl Sandbox for Styling { type Message = Message; fn new() -> Self { - Styling { - theme: style::Theme::Light, - input: text_input::State::default(), - input_value: String::new(), - button: button::State::default(), - } + Styling::default() } fn title(&self) -> String { @@ -106,6 +102,12 @@ mod style { pub const ALL: [Theme; 2] = [Theme::Light, Theme::Dark]; } + impl Default for Theme { + fn default() -> Theme { + Theme::Light + } + } + impl From<Theme> for Box<dyn container::StyleSheet> { fn from(theme: Theme) -> Self { match theme { |