mirror of
https://git.proxmox.com/git/proxmox
synced 2025-06-14 01:46:16 +00:00
use contains_key instead of .get().is_{some, none}()
Fixes the clippy lints: warning: unnecessary use of `get("lo").is_none()` --> proxmox-network-api/src/config/parser.rs:603:30 | 603 | if config.interfaces.get("lo").is_none() { | ------------------^^^^^^^^^^^^^^^^^^^ | | | help: replace it with: `!config.interfaces.contains_key("lo")` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_get_then_check = note: `#[warn(clippy::unnecessary_get_then_check)]` on by default Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
This commit is contained in:
parent
16aa2b74bc
commit
cb4acf6d93
@ -973,14 +973,14 @@ mod test {
|
|||||||
let node = tree.find_node(path);
|
let node = tree.find_node(path);
|
||||||
assert!(node.is_some());
|
assert!(node.is_some());
|
||||||
if let Some(node) = node {
|
if let Some(node) = node {
|
||||||
assert!(node.users.get(&user1).is_none());
|
assert!(!node.users.contains_key(&user1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for path in &user2_paths {
|
for path in &user2_paths {
|
||||||
let node = tree.find_node(path);
|
let node = tree.find_node(path);
|
||||||
assert!(node.is_some());
|
assert!(node.is_some());
|
||||||
if let Some(node) = node {
|
if let Some(node) = node {
|
||||||
assert!(node.users.get(&user2).is_some());
|
assert!(node.users.contains_key(&user2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -990,7 +990,7 @@ mod test {
|
|||||||
let node = tree.find_node(path);
|
let node = tree.find_node(path);
|
||||||
assert!(node.is_some());
|
assert!(node.is_some());
|
||||||
if let Some(node) = node {
|
if let Some(node) = node {
|
||||||
assert!(node.users.get(&user2).is_none());
|
assert!(!node.users.contains_key(&user2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ pub(crate) fn plugin_config() -> Result<(PluginData, ConfigDigest), Error> {
|
|||||||
let digest = ConfigDigest::from_slice(content.as_bytes());
|
let digest = ConfigDigest::from_slice(content.as_bytes());
|
||||||
let mut data = CONFIG.parse(plugin_cfg_filename, &content)?;
|
let mut data = CONFIG.parse(plugin_cfg_filename, &content)?;
|
||||||
|
|
||||||
if data.sections.get("standalone").is_none() {
|
if !data.sections.contains_key("standalone") {
|
||||||
let standalone = StandalonePlugin::default();
|
let standalone = StandalonePlugin::default();
|
||||||
data.set_data("standalone", "standalone", &standalone)
|
data.set_data("standalone", "standalone", &standalone)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
@ -600,7 +600,7 @@ impl<R: BufRead> NetworkParser<R> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if config.interfaces.get("lo").is_none() {
|
if !config.interfaces.contains_key("lo") {
|
||||||
let mut interface = Interface::new(String::from("lo"));
|
let mut interface = Interface::new(String::from("lo"));
|
||||||
set_method_v4(&mut interface, NetworkConfigMethod::Loopback)?;
|
set_method_v4(&mut interface, NetworkConfigMethod::Loopback)?;
|
||||||
interface.interface_type = NetworkInterfaceType::Loopback;
|
interface.interface_type = NetworkInterfaceType::Loopback;
|
||||||
|
@ -322,7 +322,7 @@ impl SectionConfig {
|
|||||||
let mut done = HashSet::new();
|
let mut done = HashSet::new();
|
||||||
|
|
||||||
for section_id in &config.order {
|
for section_id in &config.order {
|
||||||
if config.sections.get(section_id).is_none() {
|
if !config.sections.contains_key(section_id) {
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
list.push(section_id);
|
list.push(section_id);
|
||||||
|
Loading…
Reference in New Issue
Block a user