summaryrefslogtreecommitdiffstats
path: root/src/os/shared.rs
diff options
context:
space:
mode:
authorcyqsimon <28627918+cyqsimon@users.noreply.github.com>2023-08-25 20:16:33 +0800
committercyqsimon <28627918+cyqsimon@users.noreply.github.com>2023-08-25 20:16:33 +0800
commit42ae443bd3c3eb8150a8b0a0a681bc8ab315214f (patch)
treec14fd72169bddd87133d4258d9a25c8701fedc1a /src/os/shared.rs
parentfb176a5212e2e1aba41e181648723e8048da2a2c (diff)
Use variable capture syntax in format macros where possible
Diffstat (limited to 'src/os/shared.rs')
-rw-r--r--src/os/shared.rs23
1 files changed, 10 insertions, 13 deletions
diff --git a/src/os/shared.rs b/src/os/shared.rs
index ee3415a..71e491c 100644
--- a/src/os/shared.rs
+++ b/src/os/shared.rs
@@ -49,8 +49,8 @@ pub(crate) fn get_datalink_channel(
interface.name.to_owned(),
)),
_ => Err(GetInterfaceError::OtherError(format!(
- "{}: {}",
- &interface.name, e
+ "{}: {e}",
+ &interface.name
))),
},
}
@@ -97,7 +97,7 @@ where
GetInterfaceError::PermissionError(interface_name) => {
if let Some(prev_interface) = acc.permission {
return UserErrors {
- permission: Some(format!("{}, {}", prev_interface, interface_name)),
+ permission: Some(format!("{prev_interface}, {interface_name}")),
..acc
};
} else {
@@ -110,12 +110,12 @@ where
error => {
if let Some(prev_errors) = acc.other {
return UserErrors {
- other: Some(format!("{} \n {}", prev_errors, error)),
+ other: Some(format!("{prev_errors} \n {error}")),
..acc
};
} else {
return UserErrors {
- other: Some(format!("{}", error)),
+ other: Some(format!("{error}")),
..acc
};
}
@@ -128,19 +128,17 @@ where
if let Some(interface_name) = errors.permission {
if let Some(other_errors) = errors.other {
format!(
- "\n\n{}: {} \nAdditional Errors: \n {}",
- interface_name,
+ "\n\n{interface_name}: {} \nAdditional Errors: \n {other_errors}",
eperm_message(),
- other_errors
)
} else {
- format!("\n\n{}: {}", interface_name, eperm_message())
+ format!("\n\n{interface_name}: {}", eperm_message())
}
} else {
let other_errors = errors
.other
.expect("asked to collect errors but found no errors");
- format!("\n\n {}", other_errors)
+ format!("\n\n {other_errors}")
}
}
@@ -153,7 +151,7 @@ pub fn get_input(
match get_interface(name) {
Some(interface) => vec![interface],
None => {
- anyhow::bail!("Cannot find interface {}", name);
+ anyhow::bail!("Cannot find interface {name}");
// the homebrew formula relies on this wording, please be careful when changing
}
}
@@ -205,8 +203,7 @@ pub fn get_input(
let resolver = match runtime.block_on(dns::Resolver::new(dns_server)) {
Ok(resolver) => resolver,
Err(err) => anyhow::bail!(
- "Could not initialize the DNS resolver. Are you offline?\n\nReason: {:?}",
- err
+ "Could not initialize the DNS resolver. Are you offline?\n\nReason: {err:?}"
),
};
let dns_client = dns::Client::new(resolver, runtime)?;