clippy: convert single match to if let
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
This commit is contained in:
@ -566,23 +566,18 @@ pub fn get_partition_type_info() -> Result<HashMap<String, Vec<String>>, Error>
|
||||
let mut res: HashMap<String, Vec<String>> = HashMap::new();
|
||||
|
||||
let output: serde_json::Value = output.parse()?;
|
||||
match output["blockdevices"].as_array() {
|
||||
Some(list) => {
|
||||
for info in list {
|
||||
let path = match info["path"].as_str() {
|
||||
Some(p) => p,
|
||||
None => continue,
|
||||
};
|
||||
let partition_type = match info["parttype"].as_str() {
|
||||
Some(t) => t.to_owned(),
|
||||
None => continue,
|
||||
};
|
||||
let devices = res.entry(partition_type).or_insert(Vec::new());
|
||||
devices.push(path.to_string());
|
||||
}
|
||||
}
|
||||
None => {
|
||||
|
||||
if let Some(list) = output["blockdevices"].as_array() {
|
||||
for info in list {
|
||||
let path = match info["path"].as_str() {
|
||||
Some(p) => p,
|
||||
None => continue,
|
||||
};
|
||||
let partition_type = match info["parttype"].as_str() {
|
||||
Some(t) => t.to_owned(),
|
||||
None => continue,
|
||||
};
|
||||
let devices = res.entry(partition_type).or_insert(Vec::new());
|
||||
devices.push(path.to_string());
|
||||
}
|
||||
}
|
||||
Ok(res)
|
||||
|
@ -357,18 +357,12 @@ pub fn find_all_mappings() -> Result<impl Iterator<Item = (String, Option<String
|
||||
// get map of all /dev/loop mappings belonging to us
|
||||
let mut loopmap = HashMap::new();
|
||||
for ent in fs::scan_subdir(libc::AT_FDCWD, Path::new("/dev/"), &LOOPDEV_REGEX)? {
|
||||
match ent {
|
||||
Ok(ent) => {
|
||||
let loopdev = format!("/dev/{}", ent.file_name().to_string_lossy());
|
||||
match get_backing_file(&loopdev) {
|
||||
Ok(file) => {
|
||||
// insert filename only, strip RUN_DIR/
|
||||
loopmap.insert(file[RUN_DIR.len()+1..].to_owned(), loopdev);
|
||||
},
|
||||
Err(_) => {},
|
||||
}
|
||||
},
|
||||
Err(_) => {},
|
||||
if let Ok(ent) = ent {
|
||||
let loopdev = format!("/dev/{}", ent.file_name().to_string_lossy());
|
||||
if let Ok(file) = get_backing_file(&loopdev) {
|
||||
// insert filename only, strip RUN_DIR/
|
||||
loopmap.insert(file[RUN_DIR.len()+1..].to_owned(), loopdev);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user