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:
Fabian Grünbichler
2021-12-30 14:35:24 +01:00
parent 8ff886773f
commit 540fca5c9e
6 changed files with 44 additions and 67 deletions

View File

@ -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)