tree-wide: cleanup manual map/flatten
found with clippy, best viewed with `-w` ;) Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
This commit is contained in:
@ -246,10 +246,7 @@ impl BackupEnvironment {
|
||||
pub fn lookup_chunk(&self, digest: &[u8; 32]) -> Option<u32> {
|
||||
let state = self.state.lock().unwrap();
|
||||
|
||||
match state.known_chunks.get(digest) {
|
||||
Some(len) => Some(*len),
|
||||
None => None,
|
||||
}
|
||||
state.known_chunks.get(digest).map(|len| *len)
|
||||
}
|
||||
|
||||
/// Store the writer with an unique ID
|
||||
|
@ -134,11 +134,7 @@ fn get_syslog(
|
||||
mut rpcenv: &mut dyn RpcEnvironment,
|
||||
) -> Result<Value, Error> {
|
||||
|
||||
let service = if let Some(service) = param["service"].as_str() {
|
||||
Some(crate::api2::node::services::real_service_name(service))
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let service = param["service"].as_str().map(|service| crate::api2::node::services::real_service_name(service));
|
||||
|
||||
let (count, lines) = dump_journal(
|
||||
param["start"].as_u64(),
|
||||
|
@ -982,21 +982,14 @@ pub fn create_file_system(disk: &Disk, fs_type: FileSystemType) -> Result<(), Er
|
||||
|
||||
/// Block device name completion helper
|
||||
pub fn complete_disk_name(_arg: &str, _param: &HashMap<String, String>) -> Vec<String> {
|
||||
let mut list = Vec::new();
|
||||
|
||||
let dir = match proxmox_sys::fs::scan_subdir(libc::AT_FDCWD, "/sys/block", &BLOCKDEVICE_NAME_REGEX) {
|
||||
Ok(dir) => dir,
|
||||
Err(_) => return list,
|
||||
Err(_) => return vec![],
|
||||
};
|
||||
|
||||
for item in dir {
|
||||
if let Ok(item) = item {
|
||||
let name = item.file_name().to_str().unwrap().to_string();
|
||||
list.push(name);
|
||||
}
|
||||
}
|
||||
|
||||
list
|
||||
dir.flatten().map(|item| {
|
||||
item.file_name().to_str().unwrap().to_string()
|
||||
}).collect()
|
||||
}
|
||||
|
||||
/// Read the FS UUID (parse blkid output)
|
||||
|
Reference in New Issue
Block a user