Skip to content

Commit 909577b

Browse files
git-f0xwash2
authored andcommitted
chore: clippy
1 parent 4a4d5c0 commit 909577b

File tree

9 files changed

+121
-146
lines changed

9 files changed

+121
-146
lines changed

Cargo.lock

Lines changed: 24 additions & 25 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/app.rs

Lines changed: 21 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,12 @@ pub struct DialogPages {
534534
pages: VecDeque<DialogPage>,
535535
}
536536

537+
impl Default for DialogPages {
538+
fn default() -> Self {
539+
Self::new()
540+
}
541+
}
542+
537543
impl DialogPages {
538544
pub fn new() -> Self {
539545
Self {
@@ -996,7 +1002,6 @@ impl App {
9961002
self.margin = overlaps;
9971003
}
9981004

999-
#[must_use]
10001005
fn open_tab_entity(
10011006
&mut self,
10021007
location: Location,
@@ -1061,18 +1066,14 @@ impl App {
10611066
}
10621067

10631068
// This wrapper ensures that local folders use trash and remote folders permanently delete with a dialog
1064-
#[must_use]
10651069
fn delete(&mut self, paths: Vec<PathBuf>) -> Task<Message> {
10661070
let mut dialog_paths = Vec::new();
10671071
let mut trash_paths = Vec::new();
10681072

10691073
for path in paths {
10701074
//TODO: is there a smarter way to check this? (like checking for trash folders)
10711075
let can_trash = match path.metadata() {
1072-
Ok(metadata) => match tab::fs_kind(&metadata) {
1073-
tab::FsKind::Local => true,
1074-
_ => false,
1075-
},
1076+
Ok(metadata) => matches!(tab::fs_kind(&metadata), tab::FsKind::Local),
10761077
Err(err) => {
10771078
log::warn!("failed to get metadata for {:?}: {}", path, err);
10781079
false
@@ -1097,7 +1098,6 @@ impl App {
10971098
Task::batch(tasks)
10981099
}
10991100

1100-
#[must_use]
11011101
fn operation(&mut self, operation: Operation) -> Task<Message> {
11021102
let id = self.pending_operation_id;
11031103
let controller = Controller::default();
@@ -1157,7 +1157,6 @@ impl App {
11571157
}
11581158
}
11591159

1160-
#[must_use]
11611160
fn rescan_operation_selection(&mut self, op_sel: OperationSelection) -> Task<Message> {
11621161
log::info!("rescan_operation_selection {:?}", op_sel);
11631162
let entity = self.tab_model.active();
@@ -2023,7 +2022,7 @@ impl App {
20232022
}
20242023
}
20252024

2026-
return false;
2025+
false
20272026
}
20282027
}
20292028

@@ -2085,7 +2084,7 @@ impl Application for App {
20852084
.unwrap()
20862085
.block_on(async move {
20872086
while let Some(task) = compio_rx.recv().await {
2088-
_ = compio::runtime::spawn(task).detach();
2087+
compio::runtime::spawn(task).detach();
20892088
}
20902089
})
20912090
});
@@ -2242,7 +2241,7 @@ impl Application for App {
22422241

22432242
if location_opt
22442243
.and_then(|x| x.path_opt())
2245-
.map_or(false, |x| x.is_file())
2244+
.is_some_and(|x| x.is_file())
22462245
{
22472246
items.push(cosmic::widget::menu::Item::Button(
22482247
fl!("open"),
@@ -2320,14 +2319,14 @@ impl Application for App {
23202319
found |= item.path().is_some_and(|p| path.starts_with(&p))
23212320
|| item.name() == *name
23222321
|| item.uri() == *uri;
2323-
(!item.is_mounted() && found).then(|| *k)
2322+
(!item.is_mounted() && found).then_some(*k)
23242323
})
23252324
})
23262325
.or(if found {
23272326
None
23282327
} else {
23292328
// TODO do we need to choose the correct mounter?
2330-
self.mounter_items.iter().map(|(k, _)| *k).next()
2329+
self.mounter_items.keys().map(|k| *k).next()
23312330
})
23322331
{
23332332
if let Some(mounter) = MOUNTERS.get(&key) {
@@ -3079,7 +3078,7 @@ impl Application for App {
30793078
}
30803079
Message::NetworkDriveSubmit => {
30813080
//TODO: know which mounter to use for network drives
3082-
for (mounter_key, mounter) in MOUNTERS.iter() {
3081+
if let Some((mounter_key, mounter)) = MOUNTERS.iter().next() {
30833082
self.network_drive_connecting =
30843083
Some((*mounter_key, self.network_drive_input.clone()));
30853084
return mounter
@@ -3877,7 +3876,7 @@ impl Application for App {
38773876
};
38783877
let window_id = WindowId::unique();
38793878
self.windows.insert(
3880-
window_id.clone(),
3879+
window_id,
38813880
WindowKind::ContextMenu(entity, widget::Id::unique()),
38823881
);
38833882
commands.push(self.update(Message::Surface(
@@ -3901,7 +3900,7 @@ impl Application for App {
39013900
parent: parent_id.unwrap_or(
39023901
app.core
39033902
.main_window_id()
3904-
.unwrap_or_else(|| WindowId::NONE),
3903+
.unwrap_or(WindowId::NONE),
39053904
),
39063905
id: window_id,
39073906
positioner,
@@ -4062,7 +4061,7 @@ impl Application for App {
40624061
.sort_names
40634062
.get(&location_str)
40644063
.or_else(|| SORT_OPTION_FALLBACK.get(&location_str))
4065-
.unwrap_or_else(|| &(HeadingOptions::Name, true));
4064+
.unwrap_or(&(HeadingOptions::Name, true));
40664065

40674066
tab.sort_name = sort.0;
40684067
tab.sort_direction = sort.1;
@@ -4377,7 +4376,7 @@ impl Application for App {
43774376
.and_then(|x| x.path_opt())
43784377
.map(ToOwned::to_owned)
43794378
{
4380-
return self.open_file(&[path]).into();
4379+
return self.open_file(&[path]);
43814380
}
43824381
}
43834382
NavMenuAction::OpenWith(entity) => {
@@ -4635,7 +4634,7 @@ impl Application for App {
46354634
if let Some(p) = paths.first() {
46364635
{
46374636
for (k, mounter_items) in &self.mounter_items {
4638-
if let Some(mounter) = MOUNTERS.get(&k) {
4637+
if let Some(mounter) = MOUNTERS.get(k) {
46394638
if let Some(item) = mounter_items
46404639
.iter()
46414640
.find(|item| item.path().is_some_and(|path| path == *p))
@@ -4767,10 +4766,7 @@ impl Application for App {
47674766
);
47684767
}
47694768
}
4770-
4771-
let Some(dialog_page) = self.dialog_pages.front() else {
4772-
return None;
4773-
};
4769+
let dialog_page = self.dialog_pages.front()?;
47744770

47754771
let cosmic_theme::Spacing {
47764772
space_xxs, space_s, ..
@@ -4855,8 +4851,7 @@ impl Application for App {
48554851
archive_type: archive_types[index],
48564852
password: password.clone(),
48574853
})
4858-
})
4859-
.into(),
4854+
}),
48604855
])
48614856
.align_y(Alignment::Center)
48624857
.spacing(space_xxs)
@@ -5963,8 +5958,7 @@ impl Application for App {
59635958
// watching the trash which is slow but also properly get events.
59645959
let trash_paths = trash_bins
59655960
.into_iter()
5966-
.map(|path| [path.join("files"), path])
5967-
.flatten();
5961+
.flat_map(|path| [path.join("files"), path]);
59685962
for path in trash_paths {
59695963
if let Err(e) =
59705964
watcher.watch(&path, notify::RecursiveMode::NonRecursive)

0 commit comments

Comments
 (0)