Skip to content

Commit

Permalink
clippy changes
Browse files Browse the repository at this point in the history
  • Loading branch information
genusistimelord committed Nov 8, 2023
1 parent b4671fb commit b7f8dab
Show file tree
Hide file tree
Showing 11 changed files with 40 additions and 21 deletions.
9 changes: 7 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,17 @@ chrono = { version = "0.4.26", optional = true }
once_cell = { version = "1.18.0", optional = true }
itertools = { version = "0.11.0", optional = true }


[dependencies.iced_widget]
git = "https://github.com/iced-rs/iced.git"
rev = "751ea77c29f6eb3d00f45f0a04c833a1d03a425c"
#version = "0.1.1"

#[dependencies.iced_renderer]
#git = "https://github.com/iced-rs/iced.git"
#rev = "751ea77c29f6eb3d00f45f0a04c833a1d03a425c"
#features = ["wgpu"]
#version = "0.1.1"

[profile.dev.package."*"]
opt-level = 2

Expand All @@ -91,7 +96,7 @@ members = [
"examples/grid",
"examples/modal",
"examples/modal_component",
#"examples/multiple_modals",
"examples/multiple_modals",
"examples/tab_bar",
"examples/tabs",
"examples/time_picker",
Expand Down
1 change: 1 addition & 0 deletions src/native/card.rs
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,7 @@ where
}

/// Calculates the layout of the head.
#[allow(clippy::too_many_arguments)]
fn head_node<Message, Renderer>(
renderer: &Renderer,
limits: &Limits,
Expand Down
14 changes: 11 additions & 3 deletions src/native/grid/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,18 @@ fn minimum_row_column_sizes<Message, Renderer>(
Renderer: iced_widget::core::Renderer,
{
let mut children = tree.children.iter_mut();
for row in rows.iter() {
for row in rows {
let mut row_height = 0.0f32;

for (col_idx, element) in row.elements.iter().enumerate() {
let child_limits = Limits::NONE.width(Length::Shrink).height(Length::Shrink);
let Size { width, height } = element
.as_widget()
.layout(children.next().unwrap(), renderer, &child_limits)
.layout(
children.next().expect("grid missing expected child"),
renderer,
&child_limits,
)
.size();

#[allow(clippy::option_if_let_else)]
Expand Down Expand Up @@ -200,7 +204,11 @@ where
.max_width(column_width)
.max_height(row_height);

let mut node = widget.layout(children.next().unwrap(), renderer, &widget_limits);
let mut node = widget.layout(
children.next().expect("Grid missing child"),
renderer,
&widget_limits,
);
node.move_to(Point::new(x, y));
node.align(
horizontal_alignment.into(),
Expand Down
1 change: 1 addition & 0 deletions src/native/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! Stateless, pure widgets for iced
//use iced_widget::{renderer, style};
pub mod helpers;
#[allow(unused_imports)]
pub use helpers::*;

pub mod overlay;
Expand Down
4 changes: 2 additions & 2 deletions src/native/number_input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ where
)
};

let mut input_tree = if let Some(child_tree) = tree.children.get_mut(1) {
let input_tree = if let Some(child_tree) = tree.children.get_mut(1) {
child_tree.diff(element.as_widget());
child_tree
} else {
Expand All @@ -343,7 +343,7 @@ where

let mut modifier = element
.as_widget()
.layout(&mut input_tree, renderer, &limits2.loose());
.layout(input_tree, renderer, &limits2.loose());
let intrinsic = Size::new(
content.size().width - 1.0,
content.size().height.max(modifier.size().height),
Expand Down
6 changes: 3 additions & 3 deletions src/native/overlay/color_picker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -906,7 +906,7 @@ where
.width(Length::Fill)
.height(Length::FillPortion(1)),
)
.layout(&mut color_picker.tree, renderer, &block1_limits);
.layout(color_picker.tree, renderer, &block1_limits);

block1_node.move_to(Point::new(bounds.x + PADDING, bounds.y + PADDING));

Expand Down Expand Up @@ -977,7 +977,7 @@ where
);
}
let element: Element<Message, Renderer<Theme>> = Element::new(rgba_colors);
let mut rgba_tree = if let Some(child_tree) = color_picker.tree.children.get_mut(2) {
let rgba_tree = if let Some(child_tree) = color_picker.tree.children.get_mut(2) {
child_tree.diff(element.as_widget());
child_tree
} else {
Expand All @@ -988,7 +988,7 @@ where

let mut rgba_colors = element
.as_widget()
.layout(&mut rgba_tree, renderer, &block2_limits);
.layout(rgba_tree, renderer, &block2_limits);

rgba_colors.move_to(Point::new(
rgba_colors.bounds().x + PADDING,
Expand Down
4 changes: 2 additions & 2 deletions src/native/overlay/date_picker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ where
.push(days);

let element: Element<Message, Renderer<Theme>> = Element::new(col);
let mut col_tree = if let Some(child_tree) = self.tree.children.get_mut(2) {
let col_tree = if let Some(child_tree) = self.tree.children.get_mut(2) {
child_tree.diff(element.as_widget());
child_tree
} else {
Expand All @@ -479,7 +479,7 @@ where
&mut self.tree.children[2]
};

let mut col = element.as_widget().layout(&mut col_tree, renderer, &limits);
let mut col = element.as_widget().layout(col_tree, renderer, &limits);
col.move_to(Point::new(
col.bounds().x + PADDING,
col.bounds().y + PADDING,
Expand Down
2 changes: 1 addition & 1 deletion src/native/overlay/floating_element.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ where
let mut node = self
.element
.as_widget()
.layout(&mut self.state, renderer, &limits);
.layout(self.state, renderer, &limits);

let position = match self.anchor {
Anchor::NorthWest => Point::new(position.x + self.offset.x, position.y + self.offset.y),
Expand Down
2 changes: 1 addition & 1 deletion src/native/overlay/modal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ where
let mut content = self
.content
.as_widget()
.layout(&mut self.state, renderer, &limits);
.layout(self.state, renderer, &limits);
let max_size = limits.max();

content.align(
Expand Down
2 changes: 1 addition & 1 deletion src/native/overlay/time_picker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ where
let mut clock = Row::<(), Renderer<Theme>>::new()
.width(Length::Fill)
.height(Length::Fill)
.layout(&mut self.tree, renderer, &limits);
.layout(self.tree, renderer, &limits);

clock.move_to(Point::new(
clock.bounds().x + PADDING,
Expand Down
16 changes: 10 additions & 6 deletions src/native/wrap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -377,9 +377,11 @@ where
Size::new(limits.min().width, line_minimal_length),
limits.max(),
);
let mut node =
elem.as_widget()
.layout(&mut children.next().unwrap(), renderer, &node_limit);
let mut node = elem.as_widget().layout(
children.next().expect("wrap missing expected child"),
renderer,
&node_limit,
);

let size = node.size();

Expand Down Expand Up @@ -462,9 +464,11 @@ where
Size::new(line_minimal_length, limits.min().height),
limits.max(),
);
let mut node =
elem.as_widget()
.layout(&mut children.next().unwrap(), renderer, &node_limit);
let mut node = elem.as_widget().layout(
children.next().expect("wrap missing expected child"),
renderer,
&node_limit,
);

let size = node.size();

Expand Down

0 comments on commit b7f8dab

Please sign in to comment.