Skip to content

Commit

Permalink
Clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
latidoremi committed Aug 4, 2023
1 parent 53bec13 commit 3046344
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions src/native/menu/menu_inner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ impl MenuState {
max_index,
upper_bound_rel,
positions,
&sizes,
sizes,
)
.min(max_index);

Expand Down Expand Up @@ -1062,6 +1062,7 @@ where
Captured
}

#[allow(clippy::pedantic)]
/// Returns (children_size, child_positions, child_sizes)
fn get_children_layout<Message, Renderer>(
menu_tree: &MenuTree<'_, Message, Renderer>,
Expand All @@ -1080,20 +1081,20 @@ where
let child_sizes: Vec<Size> = match item_height {
ItemHeight::Uniform(u) => {
let count = menu_tree.children.len();
(0..count).map(|_| Size::new(width, u as f32)).collect()
(0..count).map(|_| Size::new(width, f32::from(u))).collect()
}
ItemHeight::Static(s) => menu_tree
.children
.iter()
.map(|mt| Size::new(width, mt.height.unwrap_or(s) as f32))
.map(|mt| Size::new(width, f32::from(mt.height.unwrap_or(s))))
.collect(),
ItemHeight::Dynamic(d) => menu_tree
.children
.iter()
.map(|mt| {
let w = mt.item.as_widget();
match w.height() {
Length::Fixed(f) => Size::new(width, f as f32),
Length::Fixed(f) => Size::new(width, f),
Length::Shrink => {
let l_height = w
.layout(
Expand All @@ -1104,20 +1105,17 @@ where
.height;

let height = if (f32::MAX - l_height) < 0.001 {
d as f32
f32::from(d)
} else {
l_height
};

Size::new(width, height)
}
_ => {
if let Some(h) = mt.height {
Size::new(width, h as f32)
} else {
Size::new(width, d as f32)
}
}
_ => mt.height.map_or_else(
|| Size::new(width, f32::from(d)),
|h| Size::new(width, f32::from(h)),
),
}
})
.collect(),
Expand Down

0 comments on commit 3046344

Please sign in to comment.