From 0766da7509d81e1c451ac8364ee7cbdc52dd0265 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Mon, 6 Apr 2020 01:14:38 +0100 Subject: [PATCH] add helper for settings flags init --- src/settings.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/settings.rs b/src/settings.rs index ea96961747..01ad0ee044 100644 --- a/src/settings.rs +++ b/src/settings.rs @@ -34,6 +34,22 @@ pub struct Settings { pub antialiasing: bool, } +impl Settings { + /// Initialize application settings using the given data. + /// + /// [`Application`]: ../trait.Application.html + pub fn with_flags(flags: Flags) -> Self { + Self { + flags, + // not using ..Default::default() struct update syntax since it is more permissive to + // allow initializing with flags without trait bound on Default + antialiasing: Default::default(), + default_font: Default::default(), + window: Default::default(), + } + } +} + #[cfg(not(target_arch = "wasm32"))] impl From> for iced_winit::Settings { fn from(settings: Settings) -> iced_winit::Settings {