Clippy fixes

This commit is contained in:
Imbris 2020-11-01 01:13:36 -05:00
parent b84815cc0b
commit 64d885a192
10 changed files with 31 additions and 22 deletions

View File

@ -147,7 +147,7 @@ enum Mode {
Create { Create {
name: String, // TODO: default to username name: String, // TODO: default to username
body: humanoid::Body, body: humanoid::Body,
loadout: comp::Loadout, loadout: Box<comp::Loadout>,
tool: &'static str, tool: &'static str,
body_type_buttons: [button::State; 2], body_type_buttons: [button::State; 2],
@ -185,6 +185,8 @@ impl Mode {
.active_item(Some(LoadoutBuilder::default_item_config_from_str(tool))) .active_item(Some(LoadoutBuilder::default_item_config_from_str(tool)))
.build(); .build();
let loadout = Box::new(loadout);
Self::Create { Self::Create {
name, name,
body: humanoid::Body::random(), body: humanoid::Body::random(),
@ -1127,7 +1129,7 @@ impl Controls {
}) })
.into() .into()
} else { } else {
create.into() create
}; };
let bottom = Row::with_children(vec![ let bottom = Row::with_children(vec![

View File

@ -258,7 +258,8 @@ impl PlayState for MainMenuState {
&global_state.settings.language.selected_language, &global_state.settings.language.selected_language,
)); ));
localized_strings.log_missing_entries(); localized_strings.log_missing_entries();
self.main_menu_ui.update_language(localized_strings.clone()); self.main_menu_ui
.update_language(std::sync::Arc::clone(&localized_strings));
}, },
#[cfg(feature = "singleplayer")] #[cfg(feature = "singleplayer")]
MainMenuEvent::StartSingleplayer => { MainMenuEvent::StartSingleplayer => {

View File

@ -139,7 +139,7 @@ impl Screen {
let content = Column::with_children(vec![ let content = Column::with_children(vec![
text.into(), text.into(),
Container::new( Container::new(
Row::with_children(vec![cancel.into(), add.into()]) Row::with_children(vec![cancel, add])
.spacing(20) .spacing(20)
.height(Length::Units(25)), .height(Length::Units(25)),
) )

View File

@ -51,6 +51,7 @@ impl Screen {
} }
} }
#[allow(clippy::too_many_arguments)]
pub(super) fn view( pub(super) fn view(
&mut self, &mut self,
fonts: &Fonts, fonts: &Fonts,
@ -155,20 +156,18 @@ impl Screen {
.height(Length::Units(180)) .height(Length::Units(180))
.padding(20) .padding(20)
.into() .into()
} else if is_selecting_language {
self.language_selection.view(
fonts,
imgs,
i18n,
language_metadatas,
selected_language_index,
button_style,
)
} else { } else {
if is_selecting_language { self.banner
self.language_selection.view( .view(fonts, imgs, login_info, i18n, button_style)
fonts,
imgs,
i18n,
language_metadatas,
selected_language_index,
button_style,
)
} else {
self.banner
.view(fonts, imgs, login_info, i18n, button_style)
}
}; };
let central_column = Container::new(central_content) let central_column = Container::new(central_content)

View File

@ -232,7 +232,7 @@ impl Controls {
} }
fn view(&mut self, settings: &Settings, dt: f32) -> Element<Message> { fn view(&mut self, settings: &Settings, dt: f32) -> Element<Message> {
self.time = self.time + dt as f64; self.time += dt as f64;
// TODO: consider setting this as the default in the renderer // TODO: consider setting this as the default in the renderer
let button_style = style::button::Style::new(self.imgs.button) let button_style = style::button::Style::new(self.imgs.button)

View File

@ -187,7 +187,7 @@ impl IcedUi {
&self.events, &self.events,
cursor_position, cursor_position,
Some(&self.clipboard), Some(&self.clipboard),
&mut self.renderer, &self.renderer,
); );
drop(guard); drop(guard);
// Clear events // Clear events

View File

@ -799,6 +799,7 @@ impl iced::Renderer for IcedRenderer {
// TODO: use graph of primitives to enable diffing??? // TODO: use graph of primitives to enable diffing???
type Output = (Primitive, iced::mouse::Interaction); type Output = (Primitive, iced::mouse::Interaction);
#[allow(clippy::let_and_return)]
fn layout<'a, M>( fn layout<'a, M>(
&mut self, &mut self,
element: &iced::Element<'a, M, Self>, element: &iced::Element<'a, M, Self>,

View File

@ -77,6 +77,7 @@ impl slider::Renderer for IcedRenderer {
mouse::Interaction::Idle mouse::Interaction::Idle
}; };
#[allow(clippy::if_same_then_else)] // TODO: remove
let primitives = if style.labels { let primitives = if style.labels {
// TODO text label on left and right ends // TODO text label on left and right ends
vec![bar, cursor] vec![bar, cursor]

View File

@ -31,9 +31,10 @@ impl text_input::Renderer for IcedRenderer {
}; };
let mut glyph_calculator = self.cache.glyph_calculator(); let mut glyph_calculator = self.cache.glyph_calculator();
let width = glyph_calculator /* let width = */
glyph_calculator
.glyph_bounds(section) .glyph_bounds(section)
.map_or(0.0, |rect| rect.width() / p_scale); .map_or(0.0, |rect| rect.width() / p_scale)
// glyph_brush ignores the exterior spaces // glyph_brush ignores the exterior spaces
// or does it!!! // or does it!!!
@ -75,7 +76,7 @@ impl text_input::Renderer for IcedRenderer {
width += exterior_spaces as f32 * space_width; width += exterior_spaces as f32 * space_width;
}*/ }*/
width //width
} }
fn offset( fn offset(

View File

@ -63,6 +63,10 @@ impl Padding {
} }
} }
impl Default for Padding {
fn default() -> Self { Self::new() }
}
pub trait Background<R: iced::Renderer>: Sized { pub trait Background<R: iced::Renderer>: Sized {
// The intended implementors already store the state accessed in the three // The intended implementors already store the state accessed in the three
// functions below // functions below