Skip to content

Commit

Permalink
Fix clippy warnings introduced in Rust 1.67
Browse files Browse the repository at this point in the history
Done automatically with `cargo clippy --fix`

Change-type: patch
Signed-off-by: Zahari Petkov <[email protected]>
  • Loading branch information
majorz committed May 1, 2023
1 parent f67a8ea commit 1e43e97
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 89 deletions.
4 changes: 2 additions & 2 deletions src/config_json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ fn get_api_key_for_endpoint(config_json: &ConfigMap, api_endpoint: &str) -> Resu
}

pub fn read_config_json(path: &Path) -> Result<ConfigMap> {
read_json_object_file(path).context(format!("Reading {:?} failed", path))
read_json_object_file(path).context(format!("Reading {path:?} failed"))
}

fn read_json_object_file(path: &Path) -> Result<ConfigMap> {
Expand All @@ -240,7 +240,7 @@ fn json_object_from_string(contents: &str) -> Result<ConfigMap> {
}

pub fn write_config_json(path: &Path, map: &ConfigMap) -> Result<()> {
write_json_object_file(path, map).context(format!("Writing {:?} failed", path))
write_json_object_file(path, map).context(format!("Writing {path:?} failed"))
}

fn write_json_object_file(path: &Path, map: &ConfigMap) -> Result<()> {
Expand Down
3 changes: 1 addition & 2 deletions src/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ pub fn write_file(path: &Path, contents: &str, mode: Option<u32>) -> Result<()>
pub fn parse_mode(mode: &str) -> Result<Option<u32>> {
if !mode.is_empty() {
Ok(Some(u32::from_str_radix(mode, 8).context(format!(
"Parsing permission mode `{}` failed",
mode
"Parsing permission mode `{mode}` failed"
))?))
} else {
Ok(None)
Expand Down
4 changes: 2 additions & 2 deletions src/remote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ impl Configuration {
}

pub fn config_url(api_endpoint: &str, config_route: &str) -> String {
format!("{}{}", api_endpoint, config_route)
format!("{api_endpoint}{config_route}")
}

pub fn fetch_configuration(
Expand Down Expand Up @@ -91,7 +91,7 @@ fn retry_request_config(url: &str, client: &reqwest::Client) -> Result<reqwest::
}
Err(err) => {
// Print the same error only once.
let curr_err = format!("{}", err);
let curr_err = format!("{err}");
if last_err != curr_err {
info!("{}", curr_err);
last_err = curr_err;
Expand Down
16 changes: 8 additions & 8 deletions src/systemd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ const DEFAULT_MODE: &str = "replace";
const MOCK_SYSTEMD: &str = "MOCK_SYSTEMD";

pub fn start_service(name: &str) -> Result<()> {
info!("Starting {}...", name);
info!("Starting {name}...");

if should_mock_systemd() {
return Ok(());
}
start_service_impl(name).context(format!("Starting {} failed", name))
start_service_impl(name).context(format!("Starting {name} failed"))
}

fn start_service_impl(name: &str) -> Result<()> {
Expand All @@ -34,12 +34,12 @@ fn start_service_impl(name: &str) -> Result<()> {
}

pub fn stop_service(name: &str) -> Result<()> {
info!("Stopping {}...", name);
info!("Stopping {name}...");

if should_mock_systemd() {
return Ok(());
}
stop_service_impl(name).context(format!("Stopping {} failed", name))
stop_service_impl(name).context(format!("Stopping {name} failed"))
}

fn stop_service_impl(name: &str) -> Result<()> {
Expand All @@ -53,12 +53,12 @@ fn stop_service_impl(name: &str) -> Result<()> {
}

pub fn reload_or_restart_service(name: &str) -> Result<()> {
info!("Reloading or restarting {}...", name);
info!("Reloading or restarting {name}...");

if should_mock_systemd() {
return Ok(());
}
reload_or_restart_service_impl(name).context(format!("Reloading or restarting {} failed", name))
reload_or_restart_service_impl(name).context(format!("Reloading or restarting {name} failed"))
}

fn reload_or_restart_service_impl(name: &str) -> Result<()> {
Expand All @@ -72,12 +72,12 @@ fn reload_or_restart_service_impl(name: &str) -> Result<()> {
}

pub fn await_service_exit(name: &str) -> Result<()> {
info!("Awaiting {} to exit...", name);
info!("Awaiting {name} to exit...");

if should_mock_systemd() {
return Ok(());
}
await_service_exit_impl(name).context(format!("Awaiting {} to exit failed", name))
await_service_exit_impl(name).context(format!("Awaiting {name} to exit failed"))
}

fn await_service_exit_impl(name: &str) -> Result<()> {
Expand Down
Loading

0 comments on commit 1e43e97

Please sign in to comment.