summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--mullvad-cli/src/cmds/mod.rs2
-rw-r--r--mullvad-cli/src/cmds/relay.rs2
-rw-r--r--mullvad-cli/src/cmds/tunnel.rs7
-rw-r--r--mullvad-types/src/custom_tunnel.rs2
-rw-r--r--talpid-types/src/net.rs12
5 files changed, 12 insertions, 13 deletions
diff --git a/mullvad-cli/src/cmds/mod.rs b/mullvad-cli/src/cmds/mod.rs
index 613a1e69d6..02e5663d2f 100644
--- a/mullvad-cli/src/cmds/mod.rs
+++ b/mullvad-cli/src/cmds/mod.rs
@@ -43,7 +43,7 @@ pub fn get_commands() -> HashMap<&'static str, Box<Command>> {
];
let mut map = HashMap::new();
for cmd in commands {
- if let Some(_) = map.insert(cmd.name(), cmd) {
+ if map.insert(cmd.name(), cmd).is_some() {
panic!("Multiple commands with the same name");
}
}
diff --git a/mullvad-cli/src/cmds/relay.rs b/mullvad-cli/src/cmds/relay.rs
index 84f8b655f0..61f2e8d77e 100644
--- a/mullvad-cli/src/cmds/relay.rs
+++ b/mullvad-cli/src/cmds/relay.rs
@@ -205,7 +205,7 @@ impl Relay {
city.name, city.code, city.latitude, city.longitude
);
}
- println!("");
+ println!();
}
Ok(())
}
diff --git a/mullvad-cli/src/cmds/tunnel.rs b/mullvad-cli/src/cmds/tunnel.rs
index b06b7df3ee..28af8d38ea 100644
--- a/mullvad-cli/src/cmds/tunnel.rs
+++ b/mullvad-cli/src/cmds/tunnel.rs
@@ -55,7 +55,7 @@ impl Tunnel {
Self::set_openvpn_option(set_matches)
} else if let Some(_) = matches.subcommand_matches("get") {
let openvpn_options = Self::get_tunnel_options()?.openvpn;
- Self::print_openvpn_tunnel_options(&openvpn_options);
+ Self::print_openvpn_tunnel_options(openvpn_options);
Ok(())
} else {
unreachable!("Unrecognized subcommand");
@@ -85,14 +85,13 @@ impl Tunnel {
Ok(rpc.get_tunnel_options()?)
}
- fn print_openvpn_tunnel_options(options: &OpenVpnTunnelOptions) {
+ fn print_openvpn_tunnel_options(options: OpenVpnTunnelOptions) {
println!("OpenVPN tunnel options");
println!(
"\tmssfix: {}",
options
.mssfix
- .map(|v| v.to_string())
- .unwrap_or("UNSET".to_string())
+ .map_or_else(|| "UNSET".to_string(), |v| v.to_string())
);
}
}
diff --git a/mullvad-types/src/custom_tunnel.rs b/mullvad-types/src/custom_tunnel.rs
index 7edf620470..5542ef9e71 100644
--- a/mullvad-types/src/custom_tunnel.rs
+++ b/mullvad-types/src/custom_tunnel.rs
@@ -42,5 +42,5 @@ fn resolve_to_ip(host: &str) -> Result<IpAddr> {
info!("No IPv4 for host {}", host);
ipv6.pop()
})
- .ok_or(ErrorKind::InvalidHost(host.to_owned()).into())
+ .ok_or_else(|| ErrorKind::InvalidHost(host.to_owned()).into())
}
diff --git a/talpid-types/src/net.rs b/talpid-types/src/net.rs
index fff70094d0..53a2b30ab5 100644
--- a/talpid-types/src/net.rs
+++ b/talpid-types/src/net.rs
@@ -34,15 +34,15 @@ pub enum TunnelEndpointData {
}
impl TunnelEndpointData {
- pub fn port(&self) -> u16 {
- match *self {
+ pub fn port(self) -> u16 {
+ match self {
TunnelEndpointData::OpenVpn(metadata) => metadata.port,
TunnelEndpointData::Wireguard(metadata) => metadata.port,
}
}
- pub fn transport_protocol(&self) -> TransportProtocol {
- match *self {
+ pub fn transport_protocol(self) -> TransportProtocol {
+ match self {
TunnelEndpointData::OpenVpn(metadata) => metadata.protocol,
TunnelEndpointData::Wireguard(_) => TransportProtocol::Udp,
}
@@ -72,10 +72,10 @@ pub struct Endpoint {
impl Endpoint {
/// Constructs a new `Endpoint` from the given parameters.
- pub fn new<T: Into<IpAddr>>(address: T, port: u16, protocol: TransportProtocol) -> Self {
+ pub fn new(address: impl Into<IpAddr>, port: u16, protocol: TransportProtocol) -> Self {
Endpoint {
address: SocketAddr::new(address.into(), port),
- protocol: protocol,
+ protocol,
}
}
}