Skip to content

Commit

Permalink
refactor: fix new clippy errors (#234)
Browse files Browse the repository at this point in the history
* Fix clippy errors

* Update changelog

* Fix error on Windows
  • Loading branch information
fluxxcode authored Jan 19, 2025
1 parent 9d96ee9 commit bfe62bb
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
### 🔧 Changes

- Set up git-lfs to track PNG files and improve repository performance [#218](https://github.com/fluxxcode/egui-file-dialog/pull/218)
- Fixed new Clippy errors added in the latest rust version [#234](https://github.com/fluxxcode/egui-file-dialog/pull/234)

## 2024-12-17 - v0.8.0 - egui update, custom right panel and more

Expand Down
2 changes: 1 addition & 1 deletion src/data/directory_content.rs
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ fn load_directory(
fn is_path_hidden(item: &DirectoryEntry) -> bool {
use std::os::windows::fs::MetadataExt;

fs::metadata(item.as_path()).map_or(false, |metadata| metadata.file_attributes() & 0x2 > 0)
fs::metadata(item.as_path()).is_ok_and(|metadata| metadata.file_attributes() & 0x2 > 0)
}

#[cfg(not(windows))]
Expand Down
10 changes: 4 additions & 6 deletions src/file_dialog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1912,7 +1912,7 @@ impl FileDialog {
.wrap_mode(egui::TextWrapMode::Truncate)
.show_ui(ui, |ui| {
for filter in &self.config.file_filters {
let selected = selected_filter.map_or(false, |f| f.id == filter.id);
let selected = selected_filter.is_some_and(|f| f.id == filter.id);

if ui.selectable_label(selected, &filter.name).clicked() {
select_filter = Some(Some(filter.id));
Expand Down Expand Up @@ -2709,9 +2709,7 @@ impl FileDialog {
}

fn is_primary_selected(&self, item: &DirectoryEntry) -> bool {
self.selected_item
.as_ref()
.map_or(false, |x| x.path_eq(item))
self.selected_item.as_ref().is_some_and(|x| x.path_eq(item))
}

/// Resets the dialog to use default values.
Expand Down Expand Up @@ -2813,11 +2811,11 @@ impl FileDialog {
DialogMode::PickDirectory => self
.selected_item
.as_ref()
.map_or(false, crate::DirectoryEntry::is_dir),
.is_some_and(crate::DirectoryEntry::is_dir),
DialogMode::PickFile => self
.selected_item
.as_ref()
.map_or(false, DirectoryEntry::is_file),
.is_some_and(DirectoryEntry::is_file),
DialogMode::PickMultiple => self.get_dir_content_filtered_iter().any(|p| p.selected),
DialogMode::SaveFile => self.file_name_input_error.is_none(),
}
Expand Down

0 comments on commit bfe62bb

Please sign in to comment.