diff --git a/crates/ui-contract/tests/it/collection/table_trials.rs b/crates/ui-contract/tests/it/collection/table_trials.rs index a57146564..2457751dd 100644 --- a/crates/ui-contract/tests/it/collection/table_trials.rs +++ b/crates/ui-contract/tests/it/collection/table_trials.rs @@ -250,6 +250,9 @@ impl ItemSource for WithSubRow { } } +/// A step of the trial: what it does with the frames, the scene and the table's `show`. +type Act = dyn Fn(&mut Frames, &Scene, &mut dyn FnMut(&mut Ui)); + /// A sub-row's toggle cell lies at the start of its content: a press there flips it, a press in its empty toggle /// column does nothing, and a sweep down the column passes it by. #[trial] @@ -260,7 +263,7 @@ fn a_sub_rows_toggle_takes_presses_at_the_start_of_its_content() { ColumnSpec::new(NAME, "Name", ColumnWidth::Fixed(2.0 * COL)), ]) }; - let run = |act: &dyn Fn(&mut Frames, &Scene, &mut dyn FnMut(&mut Ui))| { + let run = |act: &Act| { let scene = Scene::default(); let mut frames = Frames::new(); let mut show = |ui: &mut Ui| show_table(ui, props(), &WithSubRow, &scene); diff --git a/crates/ui-widgets/src/bars/items.rs b/crates/ui-widgets/src/bars/items.rs index 6aee5816c..471a841f2 100644 --- a/crates/ui-widgets/src/bars/items.rs +++ b/crates/ui-widgets/src/bars/items.rs @@ -268,8 +268,10 @@ impl BarItems { } _ => groups.push((present.item.section, Group { items: vec![at], extent: length, keep: FitKeep::Free })), } - if present.item.keep == FitKeep::Pinned { - groups.last_mut().expect("just pushed").1.keep = FitKeep::Pinned; + if present.item.keep == FitKeep::Pinned + && let Some((_, group)) = groups.last_mut() + { + group.keep = FitKeep::Pinned; } } groups.into_iter().map(|(_, group)| group).collect() diff --git a/crates/ui-widgets/src/display/badge.rs b/crates/ui-widgets/src/display/badge.rs index a092b617a..40deb2149 100644 --- a/crates/ui-widgets/src/display/badge.rs +++ b/crates/ui-widgets/src/display/badge.rs @@ -114,7 +114,7 @@ impl Component for Badge { fn measure(&mut self, cx: &MeasureCx<'_, Self>) -> Vec2 { let text = cx.layout(&TextRun::new(cx.resolved.label).role(cx.style.text.role)).size(); - Vec2::new(text.x + self.mark_room(&cx.style, text.y), text.y) + Vec2::new(text.x + self.mark_room(cx.style, text.y), text.y) } fn sense(&self) -> Sense { @@ -126,7 +126,7 @@ impl Component for Badge { let text = if self.muted { &cx.style.muted } else { &cx.style.text }; let run = TextRun::new(cx.resolved.label).role(text.role).color(cx.resolve(&text.color)).wrap(Wrap::Elide); let content = cx.content_rect; - let room = self.mark_room(&cx.style, content.height()); + let room = self.mark_room(cx.style, content.height()); let (label, _) = Flow::new(content, cx.flow.is_rtl()).take_start((content.width() - room).max(0.0)); let layout = draw.layout(&run, label.width()); draw.galley(label.center() - layout.size() / 2.0, &layout); diff --git a/crates/ui-widgets/src/list/predicate.rs b/crates/ui-widgets/src/list/predicate.rs index 7bc979084..53845fcfe 100644 --- a/crates/ui-widgets/src/list/predicate.rs +++ b/crates/ui-widgets/src/list/predicate.rs @@ -22,7 +22,9 @@ impl RowTest<'_, K> { } /// A text for the row of a key, or none: `List::rename_draft`. -pub struct RowText<'a, K>(Box Option + 'a>); +pub struct RowText<'a, K>(RowTextFn<'a, K>); + +type RowTextFn<'a, K> = Box Option + 'a>; impl<'a, K> RowText<'a, K> { /// The text `text` gives. diff --git a/crates/ui-widgets/src/notices/notice.rs b/crates/ui-widgets/src/notices/notice.rs index dd4b15c31..ceb52d767 100644 --- a/crates/ui-widgets/src/notices/notice.rs +++ b/crates/ui-widgets/src/notices/notice.rs @@ -381,11 +381,11 @@ impl<'a> Notice<'a> { /// The sizes of the actions' faces; a centred notice's buttons all take the widest one's width. fn action_sizes(&self, cx: &MeasureCx<'_, Self>) -> Vec { - let labels = self.action_labels(cx).into_iter().enumerate(); + let labels = self.action_labels(cx); if self.row() { - return labels.map(|(_, label)| cx.face(Self::link(cx.style.message.role, label))).collect(); + return labels.into_iter().map(|label| cx.face(Self::link(cx.style.message.role, label))).collect(); } - let sizes: Vec = labels.map(|(at, label)| cx.face(Self::button(at, label))).collect(); + let sizes: Vec = labels.into_iter().enumerate().map(|(at, label)| cx.face(Self::button(at, label))).collect(); let widest = sizes.iter().map(|size| size.x).fold(0.0, f32::max); sizes.into_iter().map(|size| Vec2::new(widest, size.y)).collect() }