From fbc25f8d3d94be148663dbbe1de6ceb9c162b308 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Mon, 6 Jan 2020 18:46:47 +0100 Subject: Implement `Default` for `Theme` in `styling` example --- examples/styling.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'examples/styling.rs') 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 for Box { fn from(theme: Theme) -> Self { match theme { -- cgit