clippy: remove unnecessary closures
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
This commit is contained in:
parent
4428818412
commit
22a9189ee0
@ -169,7 +169,7 @@ pub fn list_users(
|
||||
})
|
||||
.collect()
|
||||
} else {
|
||||
iter.map(|user: user::User| UserWithTokens::new(user))
|
||||
iter.map(UserWithTokens::new)
|
||||
.collect()
|
||||
};
|
||||
|
||||
|
@ -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<i64> {
|
||||
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)
|
||||
})();
|
||||
}
|
||||
|
||||
|
@ -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<i64> {
|
||||
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)
|
||||
})();
|
||||
}
|
||||
|
||||
|
@ -60,7 +60,7 @@ impl FixedIndexReader {
|
||||
pub fn open(path: &Path) -> Result<Self, Error> {
|
||||
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))
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
@ -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),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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,
|
||||
|
@ -527,7 +527,7 @@ impl TapeDriver for LinuxTapeHandle {
|
||||
let result: Result<u64, String> = 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
|
||||
|
@ -37,7 +37,7 @@ pub fn read_pkg_state() -> Result<Option<PkgState>, 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))
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user