Skip to content

Commit

Permalink
chore: make clippy happy
Browse files Browse the repository at this point in the history
  • Loading branch information
rapiz1 committed Mar 9, 2022
1 parent d842fbb commit d2c55cc
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"
))?;

Expand Down
6 changes: 3 additions & 3 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
}
Expand Down
2 changes: 1 addition & 1 deletion src/helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)> {
Expand Down
2 changes: 1 addition & 1 deletion src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
2 changes: 1 addition & 1 deletion src/transport/tls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down

0 comments on commit d2c55cc

Please sign in to comment.