From 22a9189ee0ffc001eb5851859a514c3ab2fd053a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Gr=C3=BCnbichler?= Date: Fri, 15 Jan 2021 15:21:34 +0100 Subject: [PATCH] clippy: remove unnecessary closures MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Fabian Grünbichler --- src/api2/access/user.rs | 2 +- src/api2/admin/sync.rs | 4 ++-- src/api2/admin/verify.rs | 4 ++-- src/backup/fixed_index.rs | 2 +- src/bin/proxmox-backup-client.rs | 2 +- src/config/acl.rs | 16 ++++++++-------- src/pxar/extract.rs | 2 +- src/server/worker_task.rs | 3 +-- src/tape/drive/linux_tape.rs | 2 +- src/tools/apt.rs | 2 +- 10 files changed, 19 insertions(+), 20 deletions(-) diff --git a/src/api2/access/user.rs b/src/api2/access/user.rs index ea583b1d..9af15b69 100644 --- a/src/api2/access/user.rs +++ b/src/api2/access/user.rs @@ -169,7 +169,7 @@ pub fn list_users( }) .collect() } else { - iter.map(|user: user::User| UserWithTokens::new(user)) + iter.map(UserWithTokens::new) .collect() }; diff --git a/src/api2/admin/sync.rs b/src/api2/admin/sync.rs index 3a808b22..41d01a4b 100644 --- a/src/api2/admin/sync.rs +++ b/src/api2/admin/sync.rs @@ -81,13 +81,13 @@ pub fn list_sync_jobs( job.last_run_state = state; job.last_run_endtime = endtime; - let last = job.last_run_endtime.unwrap_or_else(|| starttime); + let last = job.last_run_endtime.unwrap_or(starttime); job.next_run = (|| -> Option { let schedule = job.schedule.as_ref()?; let event = parse_calendar_event(&schedule).ok()?; // ignore errors - compute_next_event(&event, last, false).unwrap_or_else(|_| None) + compute_next_event(&event, last, false).unwrap_or(None) })(); } diff --git a/src/api2/admin/verify.rs b/src/api2/admin/verify.rs index 6c345cd8..0337adcb 100644 --- a/src/api2/admin/verify.rs +++ b/src/api2/admin/verify.rs @@ -86,13 +86,13 @@ pub fn list_verification_jobs( job.last_run_state = state; job.last_run_endtime = endtime; - let last = job.last_run_endtime.unwrap_or_else(|| starttime); + let last = job.last_run_endtime.unwrap_or(starttime); job.next_run = (|| -> Option { let schedule = job.schedule.as_ref()?; let event = parse_calendar_event(&schedule).ok()?; // ignore errors - compute_next_event(&event, last, false).unwrap_or_else(|_| None) + compute_next_event(&event, last, false).unwrap_or(None) })(); } diff --git a/src/backup/fixed_index.rs b/src/backup/fixed_index.rs index 7ac41b13..279537de 100644 --- a/src/backup/fixed_index.rs +++ b/src/backup/fixed_index.rs @@ -60,7 +60,7 @@ impl FixedIndexReader { pub fn open(path: &Path) -> Result { File::open(path) .map_err(Error::from) - .and_then(|file| Self::new(file)) + .and_then(Self::new) .map_err(|err| format_err!("Unable to open fixed index {:?} - {}", path, err)) } diff --git a/src/bin/proxmox-backup-client.rs b/src/bin/proxmox-backup-client.rs index 96e47588..b5677cdb 100644 --- a/src/bin/proxmox-backup-client.rs +++ b/src/bin/proxmox-backup-client.rs @@ -898,7 +898,7 @@ async fn create_backup( } } - let backup_time = backup_time_opt.unwrap_or_else(|| epoch_i64()); + let backup_time = backup_time_opt.unwrap_or_else(epoch_i64); let client = connect(&repo)?; record_repository(&repo); diff --git a/src/config/acl.rs b/src/config/acl.rs index 3ad17eb5..32fb0b9b 100644 --- a/src/config/acl.rs +++ b/src/config/acl.rs @@ -402,7 +402,7 @@ impl AclTreeNode { } fn insert_group_role(&mut self, group: String, role: String, propagate: bool) { - let map = self.groups.entry(group).or_insert_with(|| HashMap::new()); + let map = self.groups.entry(group).or_insert_with(HashMap::new); if role == ROLE_NAME_NO_ACCESS { map.clear(); map.insert(role, propagate); @@ -413,7 +413,7 @@ impl AclTreeNode { } fn insert_user_role(&mut self, auth_id: Authid, role: String, propagate: bool) { - let map = self.users.entry(auth_id).or_insert_with(|| HashMap::new()); + let map = self.users.entry(auth_id).or_insert_with(HashMap::new); if role == ROLE_NAME_NO_ACCESS { map.clear(); map.insert(role, propagate); @@ -455,7 +455,7 @@ impl AclTree { node = node .children .entry(String::from(*comp)) - .or_insert_with(|| AclTreeNode::new()); + .or_insert_with(AclTreeNode::new); } node } @@ -521,12 +521,12 @@ impl AclTree { if *propagate { role_ug_map1 .entry(role) - .or_insert_with(|| BTreeSet::new()) + .or_insert_with(BTreeSet::new) .insert(auth_id); } else { role_ug_map0 .entry(role) - .or_insert_with(|| BTreeSet::new()) + .or_insert_with(BTreeSet::new) .insert(auth_id); } } @@ -538,12 +538,12 @@ impl AclTree { if *propagate { role_ug_map1 .entry(role) - .or_insert_with(|| BTreeSet::new()) + .or_insert_with(BTreeSet::new) .insert(group); } else { role_ug_map0 .entry(role) - .or_insert_with(|| BTreeSet::new()) + .or_insert_with(BTreeSet::new) .insert(group); } } @@ -563,7 +563,7 @@ impl AclTree { }); result_map .entry(item_list) - .or_insert_with(|| BTreeSet::new()) + .or_insert_with(BTreeSet::new) .insert(item.to_string()); } result_map diff --git a/src/pxar/extract.rs b/src/pxar/extract.rs index ed238a2c..12f9054d 100644 --- a/src/pxar/extract.rs +++ b/src/pxar/extract.rs @@ -228,7 +228,7 @@ impl Extractor { allow_existing_dirs, feature_flags, current_path: Arc::new(Mutex::new(OsString::new())), - on_error: Box::new(|err| Err(err)), + on_error: Box::new(Err), } } diff --git a/src/server/worker_task.rs b/src/server/worker_task.rs index 46fe9664..3ac618b0 100644 --- a/src/server/worker_task.rs +++ b/src/server/worker_task.rs @@ -362,8 +362,7 @@ fn update_active_workers(new_upid: Option<&UPID>) -> Result<(), Error> { if !worker_is_active_local(&info.upid) { // println!("Detected stopped task '{}'", &info.upid_str); let now = proxmox::tools::time::epoch_i64(); - let status = upid_read_status(&info.upid) - .unwrap_or_else(|_| TaskState::Unknown { endtime: now }); + let status = upid_read_status(&info.upid).unwrap_or(TaskState::Unknown { endtime: now }); finish_list.push(TaskListInfo { upid: info.upid, upid_str: info.upid_str, diff --git a/src/tape/drive/linux_tape.rs b/src/tape/drive/linux_tape.rs index a23524a7..fab8a2ca 100644 --- a/src/tape/drive/linux_tape.rs +++ b/src/tape/drive/linux_tape.rs @@ -527,7 +527,7 @@ impl TapeDriver for LinuxTapeHandle { let result: Result = serde_json::from_str(&output)?; result .map_err(|err| format_err!("{}", err)) - .map(|bits| TapeAlertFlags::from_bits_truncate(bits)) + .map(TapeAlertFlags::from_bits_truncate) } /// Set or clear encryption key diff --git a/src/tools/apt.rs b/src/tools/apt.rs index af8f51f1..f4734432 100644 --- a/src/tools/apt.rs +++ b/src/tools/apt.rs @@ -37,7 +37,7 @@ pub fn read_pkg_state() -> Result, Error> { }; serde_json::from_str(&serialized_state) - .map(|s| Some(s)) + .map(Some) .map_err(|err| format_err!("could not parse cached package status - {}", err)) }