diff --git a/src/generate_conf.rs b/src/generate_conf.rs index c838246..a6af51b 100644 --- a/src/generate_conf.rs +++ b/src/generate_conf.rs @@ -102,11 +102,13 @@ fn extract_interfaces( .expect("Unable to read nmconnection file"); let id = config.get("connection", "id"); let interface_name = config.get("connection", "interface-name"); - if id.is_some() && interface_name.is_some() { - config_files_map - .entry(interface_name.unwrap().to_string()) - .or_insert_with(|| Vec::new()) - .push(id.unwrap().clone()); + if let Some(interface_name_value) = interface_name { + if let Some(id_value) = id { + config_files_map + .entry(interface_name_value.to_string()) + .or_default() + .push(id_value.clone()); + } } } @@ -120,7 +122,7 @@ fn extract_interfaces( interface_type: i.iface_type().to_string(), connection_ids: config_files_map .get(i.name()) - .map(Vec::clone) + .cloned() .or_else(|| Some(Vec::new())), }) .collect()