chore: make clippy happy

This commit is contained in:
Yujia Qiao 2022-03-09 12:34:29 +08:00
parent d842fbb2da
commit d2c55cc99c
No known key found for this signature in database
GPG Key ID: DC129173B148701B
5 changed files with 7 additions and 7 deletions

View File

@ -33,7 +33,7 @@ pub async fn run_client(
shutdown_rx: broadcast::Receiver<bool>,
service_rx: mpsc::Receiver<ServiceChange>,
) -> Result<()> {
let config = config.client.ok_or(anyhow!(
let config = config.client.ok_or_else(|| anyhow!(
"Try to run as a client, but the configuration is missing. Please add the `[client]` block"
))?;

View File

@ -289,18 +289,18 @@ impl Config {
let tls_config = config
.tls
.as_ref()
.ok_or(anyhow!("Missing TLS configuration"))?;
.ok_or_else(|| anyhow!("Missing TLS configuration"))?;
if is_server {
tls_config
.pkcs12
.as_ref()
.and(tls_config.pkcs12_password.as_ref())
.ok_or(anyhow!("Missing `pkcs12` or `pkcs12_password`"))?;
.ok_or_else(|| anyhow!("Missing `pkcs12` or `pkcs12_password`"))?;
} else {
tls_config
.trusted_root
.as_ref()
.ok_or(anyhow!("Missing `trusted_root`"))?;
.ok_or_else(|| anyhow!("Missing `trusted_root`"))?;
}
Ok(())
}

View File

@ -44,7 +44,7 @@ async fn to_socket_addr<A: ToSocketAddrs>(addr: A) -> Result<SocketAddr> {
lookup_host(addr)
.await?
.next()
.ok_or(anyhow!("Failed to lookup the host"))
.ok_or_else(|| anyhow!("Failed to lookup the host"))
}
pub fn host_port_pair(s: &str) -> Result<(&str, u16)> {

View File

@ -676,7 +676,7 @@ async fn run_udp_connection_pool<T: Transport>(
let mut conn = data_ch_rx
.recv()
.await
.ok_or(anyhow!("No available data channels"))?;
.ok_or_else(|| anyhow!("No available data channels"))?;
conn.write_all(&cmd).await?;
let mut buf = [0u8; UDP_BUFFER_SIZE];

View File

@ -26,7 +26,7 @@ impl Transport for TlsTransport {
fn new(config: &TransportConfig) -> Result<Self> {
let tcp = TcpTransport::new(config)?;
let config = config.tls.as_ref().ok_or(anyhow!("Missing tls config"))?;
let config = config.tls.as_ref().ok_or_else(|| anyhow!("Missing tls config"))?;
let connector = match config.trusted_root.as_ref() {
Some(path) => {