Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add init method for settings with flags #266

Merged
merged 1 commit into from
Apr 6, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,22 @@ pub struct Settings<Flags> {
pub antialiasing: bool,
}

impl<Flags> Settings<Flags> {
/// 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<Flags> From<Settings<Flags>> for iced_winit::Settings<Flags> {
fn from(settings: Settings<Flags>) -> iced_winit::Settings<Flags> {
Expand Down