chore: apply clippy suggestions

This commit is contained in:
Cheong Lau 2025-10-05 12:27:32 +10:00 committed by Michael Murphy
parent 34f55d6720
commit a27bb5e05d
34 changed files with 116 additions and 146 deletions

View file

@ -229,7 +229,7 @@ impl Config {
// Start a transaction (to set multiple configs at the same time)
#[inline]
pub fn transaction(&self) -> ConfigTransaction {
pub fn transaction(&self) -> ConfigTransaction<'_> {
ConfigTransaction {
config: self,
updates: Mutex::new(Vec::new()),

View file

@ -93,7 +93,7 @@ async fn start_listening<T: 'static + Send + Sync + PartialEq + Clone + CosmicCo
}
Err((errors, t)) => {
let update = crate::Update {
errors: errors,
errors,
keys: Vec::new(),
config: t.clone(),
};

View file

@ -814,7 +814,7 @@ pub struct ThemeBuilder {
impl Default for ThemeBuilder {
fn default() -> Self {
Self {
palette: DARK_PALETTE.to_owned().into(),
palette: DARK_PALETTE.to_owned(),
spacing: Spacing::default(),
corner_radii: CornerRadii::default(),
neutral_tint: Default::default(),
@ -1077,7 +1077,7 @@ impl ThemeBuilder {
component_pressed_overlay = component_hovered_overlay;
component_pressed_overlay.alpha = 0.2;
let container = Container::new(
Container::new(
Component::component(
component_base,
accent,
@ -1101,9 +1101,7 @@ impl ThemeBuilder {
),
get_small_widget_color(base_index, 5, &neutral_steps, &control_steps_array[6]),
is_high_contrast,
);
container
)
};
let accent_text = if is_dark {

View file

@ -93,7 +93,7 @@ pub fn get_text(
let index = get_index(base_index, 70, step_array.len(), is_dark)
.or_else(|| get_index(base_index, 50, step_array.len(), is_dark))
.unwrap_or_else(|| if is_dark { 99 } else { 0 });
.unwrap_or(if is_dark { 99 } else { 0 });
*step_array.get(index).unwrap_or(fallback)
}

View file

@ -114,7 +114,7 @@ where
(
Self::new(model),
Task::batch(vec![
Task::batch([
command,
iced_runtime::window::run_with_handle(id, init_windowing_system),
]),
@ -665,23 +665,21 @@ impl<T: Application> Cosmic<T> {
bottom_left: radii[3].round() as u32,
};
let rounded = !self.app.core().window.sharp_corners;
return Task::batch(vec![
corner_radius(
id,
if rounded {
Some(cur_rad)
} else {
let rad_0 = t.radius_0();
Some(CornerRadius {
top_left: rad_0[0].round() as u32,
top_right: rad_0[1].round() as u32,
bottom_right: rad_0[2].round() as u32,
bottom_left: rad_0[3].round() as u32,
})
},
)
.discard(),
]);
return Task::batch([corner_radius(
id,
if rounded {
Some(cur_rad)
} else {
let rad_0 = t.radius_0();
Some(CornerRadius {
top_left: rad_0[0].round() as u32,
top_right: rad_0[1].round() as u32,
bottom_right: rad_0[2].round() as u32,
bottom_left: rad_0[3].round() as u32,
})
},
)
.discard()]);
}
}
@ -1061,7 +1059,7 @@ impl<T: Application> Cosmic<T> {
if core.exit_on_main_window_closed
&& core.main_window_id().is_some_and(|m_id| id == m_id)
{
ret = Task::batch(vec![iced::exit::<crate::Action<T::Message>>()]);
ret = Task::batch([iced::exit::<crate::Action<T::Message>>()]);
}
return ret;
}
@ -1231,7 +1229,7 @@ impl<T: Application> Cosmic<T> {
// TODO do we need per window sharp corners?
let rounded = !self.app.core().window.sharp_corners;
return Task::batch(vec![
return Task::batch([
corner_radius(
id,
if rounded {
@ -1326,9 +1324,9 @@ impl<App: Application> Cosmic<App> {
>,
) -> Task<crate::Action<App::Message>> {
use iced_winit::SurfaceIdWrapper;
*self.opened_surfaces.entry(id.clone()).or_insert_with(|| 0) += 1;
*self.opened_surfaces.entry(id).or_insert(0) += 1;
self.surface_views.insert(
id.clone(),
id,
(
None, // TODO parent for window, platform specific option maybe?
SurfaceIdWrapper::Window(id),

View file

@ -420,10 +420,10 @@ where
}
/// Constructs the view for the main window.
fn view(&self) -> Element<Self::Message>;
fn view(&self) -> Element<'_, Self::Message>;
/// Constructs views for other windows.
fn view_window(&self, id: window::Id) -> Element<Self::Message> {
fn view_window(&self, id: window::Id) -> Element<'_, Self::Message> {
panic!("no view for window {id:?}");
}

View file

@ -136,7 +136,7 @@ pub fn load_applications_for_app_ids<'a>(
}
#[cfg(not(windows))]
pub fn load_desktop_file<'a>(locales: &'a [String], path: PathBuf) -> Option<DesktopEntryData> {
pub fn load_desktop_file(locales: &[String], path: PathBuf) -> Option<DesktopEntryData> {
fde::DesktopEntry::from_path(path, Some(locales))
.ok()
.map(|de| DesktopEntryData::from_desktop_entry(locales, de))
@ -144,10 +144,7 @@ pub fn load_desktop_file<'a>(locales: &'a [String], path: PathBuf) -> Option<Des
#[cfg(not(windows))]
impl DesktopEntryData {
pub fn from_desktop_entry<'a>(
locales: &'a [String],
de: fde::DesktopEntry,
) -> DesktopEntryData {
pub fn from_desktop_entry(locales: &[String], de: fde::DesktopEntry) -> DesktopEntryData {
let name = de
.name(locales)
.unwrap_or(Cow::Borrowed(&de.appid))

View file

@ -120,6 +120,12 @@ impl Dialog {
}
}
impl Default for Dialog {
fn default() -> Self {
Self::new()
}
}
#[cfg(feature = "xdg-portal")]
mod portal {
use super::Dialog;

View file

@ -22,15 +22,15 @@ pub type CosmicColor = ::palette::rgb::Srgba;
pub type CosmicComponent = cosmic_theme::Component;
pub type CosmicTheme = cosmic_theme::Theme;
pub static COSMIC_DARK: LazyLock<CosmicTheme> = LazyLock::new(|| CosmicTheme::dark_default());
pub static COSMIC_DARK: LazyLock<CosmicTheme> = LazyLock::new(CosmicTheme::dark_default);
pub static COSMIC_HC_DARK: LazyLock<CosmicTheme> =
LazyLock::new(|| CosmicTheme::high_contrast_dark_default());
LazyLock::new(CosmicTheme::high_contrast_dark_default);
pub static COSMIC_LIGHT: LazyLock<CosmicTheme> = LazyLock::new(|| CosmicTheme::light_default());
pub static COSMIC_LIGHT: LazyLock<CosmicTheme> = LazyLock::new(CosmicTheme::light_default);
pub static COSMIC_HC_LIGHT: LazyLock<CosmicTheme> =
LazyLock::new(|| CosmicTheme::high_contrast_light_default());
LazyLock::new(CosmicTheme::high_contrast_light_default);
pub static TRANSPARENT_COMPONENT: LazyLock<Component> = LazyLock::new(|| Component {
base: CosmicColor::new(0.0, 0.0, 0.0, 0.0),

View file

@ -898,12 +898,10 @@ impl toggler::Catalog for Theme {
let mut active = toggler::Style {
background: if matches!(status, toggler::Status::Active { is_toggled: true }) {
cosmic.accent.base.into()
} else if cosmic.is_dark {
cosmic.palette.neutral_6.into()
} else {
if cosmic.is_dark {
cosmic.palette.neutral_6.into()
} else {
cosmic.palette.neutral_5.into()
}
cosmic.palette.neutral_5.into()
},
foreground: cosmic.palette.neutral_2.into(),
border_radius: cosmic.radius_xl().into(),
@ -1166,11 +1164,7 @@ impl scrollable::Catalog for Theme {
},
gap: None,
};
let small_widget_container = self
.current_container()
.small_widget
.clone()
.with_alpha(0.7);
let small_widget_container = self.current_container().small_widget.with_alpha(0.7);
if matches!(class, Scrollable::Permanent) {
a.horizontal_rail.background =
@ -1233,11 +1227,8 @@ impl scrollable::Catalog for Theme {
};
if matches!(class, Scrollable::Permanent) {
let small_widget_container = self
.current_container()
.small_widget
.clone()
.with_alpha(0.7);
let small_widget_container =
self.current_container().small_widget.with_alpha(0.7);
a.horizontal_rail.background =
Some(Background::Color(small_widget_container.into()));

View file

@ -152,13 +152,11 @@ pub fn about<'a, Message: Clone + 'static>(
let artists_section = section(&about.artists, fl!("artists"));
let translators_section = section(&about.translators, fl!("translators"));
let documenters_section = section(&about.documenters, fl!("documenters"));
let license_section = about.license.as_ref().and_then(|license| {
let license_section = about.license.as_ref().map(|license| {
let url = about.license_url.as_deref().unwrap_or_default();
Some(
widget::settings::section()
.title(fl!("license"))
.add(section_button(license, url)),
)
widget::settings::section()
.title(fl!("license"))
.add(section_button(license, url))
});
let copyright = about.copyright.as_ref().map(widget::text::body);
let comments = about.comments.as_ref().map(widget::text::body);

View file

@ -793,7 +793,7 @@ pub fn update<'a, Message: Clone>(
}
Event::Mouse(mouse::Event::ButtonReleased(mouse::Button::Left))
| Event::Touch(touch::Event::FingerLifted { .. }) => {
if let Some(on_press) = on_press.clone() {
if let Some(on_press) = on_press {
let state = state();
if state.is_pressed {
@ -816,9 +816,9 @@ pub fn update<'a, Message: Clone>(
#[cfg(feature = "a11y")]
Event::A11y(event_id, iced_accessibility::accesskit::ActionRequest { action, .. }) => {
let state = state();
if let Some(Some(on_press)) = (event_id == event_id
&& matches!(action, iced_accessibility::accesskit::Action::Default))
.then(|| on_press.clone())
if let Some(on_press) = matches!(action, iced_accessibility::accesskit::Action::Default)
.then_some(on_press)
.flatten()
{
state.is_pressed = false;
let msg = (on_press)(layout.virtual_offset(), layout.bounds());
@ -828,7 +828,7 @@ pub fn update<'a, Message: Clone>(
return event::Status::Captured;
}
Event::Keyboard(keyboard::Event::KeyPressed { key, .. }) => {
if let Some(on_press) = on_press.clone() {
if let Some(on_press) = on_press {
let state = state();
if state.is_focused && key == keyboard::Key::Named(keyboard::key::Named::Enter) {
state.is_pressed = true;

View file

@ -17,7 +17,7 @@ pub fn calendar<M>(
on_prev: impl Fn() -> M + 'static,
on_next: impl Fn() -> M + 'static,
first_day_of_week: Weekday,
) -> Calendar<M> {
) -> Calendar<'_, M> {
Calendar {
model,
on_select: Box::new(on_select),

View file

@ -233,7 +233,7 @@ impl ColorPickerModel {
pub fn builder<Message>(
&self,
on_update: fn(ColorPickerUpdate) -> Message,
) -> ColorPickerBuilder<Message> {
) -> ColorPickerBuilder<'_, Message> {
ColorPickerBuilder {
model: &self.segmented_model,
active_color: self.active_color,

View file

@ -673,8 +673,8 @@ pub(super) enum OptionElement<'a, S, Item> {
}
impl<S, Message> Model<S, Message> {
pub(super) fn elements(&self) -> impl Iterator<Item = OptionElement<S, Message>> + '_ {
let iterator = self.lists.iter().flat_map(|list| {
pub(super) fn elements(&self) -> impl Iterator<Item = OptionElement<'_, S, Message>> + '_ {
self.lists.iter().flat_map(|list| {
let description = list
.description
.as_ref()
@ -686,9 +686,7 @@ impl<S, Message> Model<S, Message> {
description
.chain(options)
.chain(std::iter::once(OptionElement::Separator))
});
iterator
})
}
fn element_heights(
@ -709,7 +707,7 @@ impl<S, Message> Model<S, Message> {
text_line_height: f32,
offset: f32,
height: f32,
) -> impl Iterator<Item = (OptionElement<S, Message>, f32)> + '_ {
) -> impl Iterator<Item = (OptionElement<'_, S, Message>, f32)> + '_ {
let heights = self.element_heights(padding_vertical, text_line_height);
let mut current = 0.0;

View file

@ -66,9 +66,7 @@ impl<S, Item: PartialEq> Model<S, Item> {
}
pub(super) fn next(&self) -> Option<&(S, Item)> {
let Some(item) = self.selected.as_ref() else {
return None;
};
let item = self.selected.as_ref()?;
let mut next = false;
for list in &self.lists {

View file

@ -293,11 +293,9 @@ impl<Message: Clone + 'static> Widget<Message, crate::Theme, crate::Renderer>
) -> iced_accessibility::A11yTree {
let c_layout = layout.children().next().unwrap();
let c_state = &state.children[0];
let ret = self
.header_bar_inner
self.header_bar_inner
.as_widget()
.a11y_nodes(c_layout, c_state, p);
ret
.a11y_nodes(c_layout, c_state, p)
}
}

View file

@ -97,7 +97,7 @@ impl Default for MenuBarStateInner {
}
}
pub(crate) fn menu_roots_children<Message>(menu_roots: &Vec<MenuTree<Message>>) -> Vec<Tree>
pub(crate) fn menu_roots_children<Message>(menu_roots: &[MenuTree<Message>]) -> Vec<Tree>
where
Message: Clone + 'static,
{
@ -126,7 +126,7 @@ where
}
#[allow(invalid_reference_casting)]
pub(crate) fn menu_roots_diff<Message>(menu_roots: &mut Vec<MenuTree<Message>>, tree: &mut Tree)
pub(crate) fn menu_roots_diff<Message>(menu_roots: &mut [MenuTree<Message>], tree: &mut Tree)
where
Message: Clone + 'static,
{
@ -381,7 +381,7 @@ where
let surface_action = self.on_surface_action.as_ref().unwrap();
let old_active_root = my_state
.inner
.with_data(|state| state.active_root.get(0).copied());
.with_data(|state| state.active_root.first().copied());
// if position is not on menu bar button skip.
let hovered_root = layout

View file

@ -435,7 +435,7 @@ impl MenuState {
pub(crate) struct Menu<'b, Message: std::clone::Clone> {
pub(crate) tree: MenuBarState,
// Flattened menu tree
pub(crate) menu_roots: Cow<'b, Vec<MenuTree<Message>>>,
pub(crate) menu_roots: Cow<'b, [MenuTree<Message>]>,
pub(crate) bounds_expand: u16,
/// Allows menu overlay items to overlap the parent
pub(crate) menu_overlays_parent: bool,
@ -740,7 +740,7 @@ impl<'b, Message: Clone + 'static> Menu<'b, Message> {
let styling = theme.appearance(&self.style);
let roots = active_root.iter().skip(1).fold(
&self.menu_roots[active_root[0]].children,
|mt, next_active_root| (&mt[*next_active_root].children),
|mt, next_active_root| &mt[*next_active_root].children,
);
let indices = state.get_trimmed_indices(self.depth).collect::<Vec<_>>();
state.menu_states[if self.is_overlay { 0 } else { self.depth }..=if self.is_overlay {

View file

@ -119,7 +119,7 @@ impl<Message: Clone + 'static> MenuTree<Message> {
});
mt.children.iter().for_each(|c| {
rec(&c, flat);
rec(c, flat);
});
}

View file

@ -26,7 +26,7 @@ pub type Model = segmented_button::SingleSelectModel;
pub fn nav_bar<Message: Clone + 'static>(
model: &segmented_button::SingleSelectModel,
on_activate: fn(segmented_button::Entity) -> Message,
) -> NavBar<Message> {
) -> NavBar<'_, Message> {
NavBar {
segmented_button: segmented_button::vertical(model).on_activate(on_activate),
}
@ -41,7 +41,7 @@ pub fn nav_bar_dnd<Message, D: AllowedMimeTypes>(
on_dnd_leave: impl Fn(segmented_button::Entity) -> Message + 'static,
on_dnd_drop: impl Fn(segmented_button::Entity, Option<D>, DndAction) -> Message + 'static,
id: DragId,
) -> NavBar<Message>
) -> NavBar<'_, Message>
where
Message: Clone + 'static,
{

View file

@ -132,7 +132,7 @@ impl ResponsiveMenuBar {
key_binds,
trees
.into_iter()
.map(|mt| menu::Item::Folder(mt.0, mt.1.into()))
.map(|mt| menu::Item::Folder(mt.0, mt.1))
.collect(),
)
.into_iter()

View file

@ -23,7 +23,7 @@ pub struct Horizontal;
/// For details on the model, see the [`segmented_button`](super) module for more details.
pub fn horizontal<SelectionMode: Default, Message>(
model: &Model<SelectionMode>,
) -> SegmentedButton<Horizontal, SelectionMode, Message>
) -> SegmentedButton<'_, Horizontal, SelectionMode, Message>
where
Model<SelectionMode>: Selectable,
{

View file

@ -292,7 +292,7 @@ where
/// ```
#[must_use]
#[inline]
pub fn insert(&mut self) -> EntityMut<SelectionMode> {
pub fn insert(&mut self) -> EntityMut<'_, SelectionMode> {
let id = self.items.insert(Settings::default());
self.order.push_back(id);
EntityMut { model: self, id }
@ -447,7 +447,11 @@ where
/// println!("{:?} had text {}", id, old_text)
/// }
/// ```
pub fn text_set(&mut self, id: Entity, text: impl Into<Cow<'static, str>>) -> Option<Cow<str>> {
pub fn text_set(
&mut self,
id: Entity,
text: impl Into<Cow<'static, str>>,
) -> Option<Cow<'_, str>> {
if !self.contains_item(id) {
return None;
}

View file

@ -22,7 +22,7 @@ pub type VerticalSegmentedButton<'a, SelectionMode, Message> =
/// For details on the model, see the [`segmented_button`](super) module for more details.
pub fn vertical<SelectionMode, Message>(
model: &Model<SelectionMode>,
) -> SegmentedButton<Vertical, SelectionMode, Message>
) -> SegmentedButton<'_, Vertical, SelectionMode, Message>
where
Model<SelectionMode>: Selectable,
SelectionMode: Default,

View file

@ -263,7 +263,7 @@ where
/// Check if an item is enabled.
fn is_enabled(&self, key: Entity) -> bool {
self.model.items.get(key).map_or(false, |item| item.enabled)
self.model.items.get(key).is_some_and(|item| item.enabled)
}
/// Handle the dnd drop event.
@ -987,7 +987,7 @@ where
let current = Instant::now();
// Permit successive scroll wheel events only after a given delay.
if state.wheel_timestamp.map_or(true, |previous| {
if state.wheel_timestamp.is_none_or(|previous| {
current.duration_since(previous) > Duration::from_millis(250)
}) {
state.wheel_timestamp = Some(current);
@ -1607,23 +1607,16 @@ where
let state = tree.state.downcast_ref::<LocalState>();
let menu_state = state.menu_state.clone();
let Some(entity) = state.show_context else {
return None;
};
let entity = state.show_context?;
let bounds = self
.variant_bounds(state, layout.bounds())
.find_map(|item| match item {
ItemBounds::Button(e, bounds) if e == entity => Some(bounds),
_ => None,
});
let Some(mut bounds) = bounds else {
return None;
};
let mut bounds =
self.variant_bounds(state, layout.bounds())
.find_map(|item| match item {
ItemBounds::Button(e, bounds) if e == entity => Some(bounds),
_ => None,
})?;
let Some(context_menu) = self.context_menu.as_mut() else {
return None;
};
let context_menu = self.context_menu.as_mut()?;
if !menu_state.inner.with_data(|data| data.open) {
// If the menu is not open, we don't need to show it.
@ -1777,9 +1770,8 @@ impl LocalState {
impl operation::Focusable for LocalState {
fn is_focused(&self) -> bool {
self.focused.map_or(false, |f| {
f.updated_at == LAST_FOCUS_UPDATE.with(|f| f.get())
})
self.focused
.is_some_and(|f| f.updated_at == LAST_FOCUS_UPDATE.with(|f| f.get()))
}
fn focus(&mut self) {

View file

@ -16,7 +16,7 @@ use super::segmented_button::{
/// For details on the model, see the [`segmented_button`] module for more details.
pub fn horizontal<SelectionMode: Default, Message>(
model: &Model<SelectionMode>,
) -> HorizontalSegmentedButton<SelectionMode, Message>
) -> HorizontalSegmentedButton<'_, SelectionMode, Message>
where
Model<SelectionMode>: Selectable,
{
@ -39,7 +39,7 @@ where
/// For details on the model, see the [`segmented_button`] module for more details.
pub fn vertical<SelectionMode, Message>(
model: &Model<SelectionMode>,
) -> VerticalSegmentedButton<SelectionMode, Message>
) -> VerticalSegmentedButton<'_, SelectionMode, Message>
where
Model<SelectionMode>: Selectable,
SelectionMode: Default,

View file

@ -131,7 +131,7 @@ impl<'a, Message: 'static> Item<'a, Message> {
contents.push(text(self.title).width(Length::Fill).into());
}
contents.push(widget.into());
contents.push(widget);
contents
}

View file

@ -16,7 +16,7 @@ use super::segmented_button::{
/// For details on the model, see the [`segmented_button`] module for more details.
pub fn horizontal<SelectionMode: Default, Message>(
model: &Model<SelectionMode>,
) -> HorizontalSegmentedButton<SelectionMode, Message>
) -> HorizontalSegmentedButton<'_, SelectionMode, Message>
where
Model<SelectionMode>: Selectable,
{
@ -37,7 +37,7 @@ where
/// For details on the model, see the [`segmented_button`] module for more details.
pub fn vertical<SelectionMode, Message>(
model: &Model<SelectionMode>,
) -> VerticalSegmentedButton<SelectionMode, Message>
) -> VerticalSegmentedButton<'_, SelectionMode, Message>
where
Model<SelectionMode>: Selectable,
SelectionMode: Default,

View file

@ -221,7 +221,7 @@ where
/// let id = model.insert().text("Item A").icon("custom-icon").id();
/// ```
#[must_use]
pub fn insert(&mut self, item: Item) -> EntityMut<SelectionMode, Item, Category> {
pub fn insert(&mut self, item: Item) -> EntityMut<'_, SelectionMode, Item, Category> {
let id = self.items.insert(item);
self.order.push_back(id);
EntityMut { model: self, id }
@ -244,7 +244,7 @@ where
/// ```
#[must_use]
pub fn is_enabled(&self, id: Entity) -> bool {
self.active.get(id).map_or(false, |e| *e)
self.active.get(id).is_some_and(|e| *e)
}
/// Iterates across items in the model in the order that they are displayed.
@ -288,9 +288,7 @@ where
/// }
/// ```
pub fn position_set(&mut self, id: Entity, position: u16) -> Option<usize> {
let Some(index) = self.position(id) else {
return None;
};
let index = self.position(id)?;
self.order.remove(index as usize);

View file

@ -63,7 +63,7 @@ where
.map(|entity| {
let item = val.model.item(entity).unwrap();
let selected = val.model.is_active(entity);
let context_menu = (val.item_context_builder)(&item);
let context_menu = (val.item_context_builder)(item);
widget::column()
.spacing(val.item_spacing)
@ -89,14 +89,13 @@ where
.categories
.iter()
.skip_while(|cat| **cat != Category::default())
.map(|category| {
vec![
.flat_map(|category| {
[
widget::text::caption(item.get_text(*category))
.apply(Element::from),
widget::text::caption("-").apply(Element::from),
]
})
.flatten()
.collect::<Vec<Element<'static, Message>>>();
elements.pop();
elements
@ -201,7 +200,7 @@ where
divider_padding: Padding::from(0).left(space_xxxs).right(space_xxxs),
item_padding: Padding::from(space_xxs).into(),
item_padding: Padding::from(space_xxs),
item_spacing: 0,
icon_size: 48,

View file

@ -139,13 +139,13 @@ where
} else {
val.model
.iter()
.map(move |entity| {
.flat_map(move |entity| {
let item = val.model.item(entity).unwrap();
let categories = &val.model.categories;
let selected = val.model.is_active(entity);
let item_context = (val.item_context_builder)(&item);
let item_context = (val.item_context_builder)(item);
vec![
[
divider::horizontal::default()
.apply(container)
.padding(val.divider_padding)
@ -233,13 +233,11 @@ where
.apply(Element::from),
]
})
.flatten()
.collect::<Vec<Element<'a, Message>>>()
};
vec![vec![header_row], items_full]
.into_iter()
.flatten()
.collect::<Vec<Element<'a, Message>>>()
let mut elements = items_full;
elements.insert(0, header_row);
elements
.apply(widget::column::with_children)
.width(val.width)
.height(val.height)
@ -272,7 +270,7 @@ where
width: Length::Fill,
height: Length::Shrink,
item_padding: Padding::from(space_xxs).into(),
item_padding: Padding::from(space_xxs),
item_spacing: 0,
icon_spacing: space_xxxs,
icon_size: 24,

View file

@ -546,7 +546,6 @@ where
}
/// Get the layout node of the actual text input
fn text_layout<'b>(&'a self, layout: Layout<'b>) -> Layout<'b> {
if self.dnd_icon {
layout
@ -1389,8 +1388,8 @@ pub fn update<'a, Message: Clone + 'static>(
if let Some(cursor_position) = click_position {
// Check if the edit button was clicked.
if state.dragging_state == None
&& edit_button_layout.map_or(false, |l| cursor.is_over(l.bounds()))
if state.dragging_state.is_none()
&& edit_button_layout.is_some_and(|l| cursor.is_over(l.bounds()))
{
if is_editable_variant {
state.is_read_only = !state.is_read_only;
@ -2277,7 +2276,7 @@ pub fn draw<'a, Message>(
let (cursor, offset) = if let Some(focus) =
state.is_focused.filter(|f| f.focused).or_else(|| {
let now = Instant::now();
handling_dnd_offer.then(|| Focus {
handling_dnd_offer.then_some(Focus {
needs_update: false,
updated_at: now,
now,

View file

@ -129,9 +129,7 @@ impl Value {
#[must_use]
pub fn secure(&self) -> Self {
Self {
graphemes: std::iter::repeat(String::from(""))
.take(self.graphemes.len())
.collect(),
graphemes: std::iter::repeat_n(String::from(""), self.graphemes.len()).collect(),
}
}
}