crate::tools::detect_modified_configuration_file(&digest, &expected_digest)?;
}
- if config.sections.contains_key(userid.as_str()) {
- config.sections.remove(userid.as_str());
- } else {
+ if config.sections.remove(userid.as_str()).is_none() {
bail!("user '{}' does not exist.", userid);
}
let tokenid = Authid::from((userid.clone(), Some(token_name.clone())));
let tokenid_string = tokenid.to_string();
- if config.sections.contains_key(&tokenid_string) {
- config.sections.remove(&tokenid_string);
- } else {
+ if config.sections.remove(&tokenid_string).is_none() {
bail!(
"token '{}' of user '{}' does not exist.",
token_name.as_str(),
let (mut config, _digest) = pbs_config::media_pool::config()?;
- if config.sections.contains_key(&name) {
- config.sections.remove(&name);
- } else {
+ if config.sections.remove(&name).is_none() {
http_bail!(NOT_FOUND, "delete pool '{}' failed - no such pool", name);
}
crate::tools::detect_modified_configuration_file(&digest, &expected_digest)?;
}
- if config.sections.contains_key(&name) {
- config.sections.remove(&name);
- } else {
+ if config.sections.remove(&name).is_none() {
http_bail!(NOT_FOUND, "remote '{}' does not exist.", name);
}
crate::tools::detect_modified_configuration_file(&digest, &expected_digest)?;
}
- if config.sections.contains_key(&name) {
- config.sections.remove(&name);
- } else {
+ if config.sections.remove(&name).is_none() {
http_bail!(NOT_FOUND, "traffic control rule '{}' does not exist.", name);
}