diff options
| author | Linus Färnstrand <linus@mullvad.net> | 2018-07-19 09:38:03 +0200 |
|---|---|---|
| committer | Linus Färnstrand <linus@mullvad.net> | 2018-07-19 09:38:03 +0200 |
| commit | dbadef5ad1f38e93f20187053854f45cdf7ca4a8 (patch) | |
| tree | cb16b7212fe46aa49a195940de58490875e28e68 | |
| parent | ec6248d4a431c91c6a437e5a4897911d4701347b (diff) | |
| parent | b2a058b1a9fb81357c930919466bab2ae47cbbb9 (diff) | |
| download | mullvadvpn-dbadef5ad1f38e93f20187053854f45cdf7ca4a8.tar.xz mullvadvpn-dbadef5ad1f38e93f20187053854f45cdf7ca4a8.zip | |
Merge branch 'fix-clippy-warnings'
| -rw-r--r-- | mullvad-cli/src/cmds/mod.rs | 2 | ||||
| -rw-r--r-- | mullvad-cli/src/cmds/relay.rs | 2 | ||||
| -rw-r--r-- | mullvad-cli/src/cmds/tunnel.rs | 7 | ||||
| -rw-r--r-- | mullvad-types/src/custom_tunnel.rs | 2 | ||||
| -rw-r--r-- | talpid-types/src/net.rs | 12 |
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, } } } |
