diff --git a/src/connect.rs b/src/connect.rs index 3ad374021..1a9bd5343 100644 --- a/src/connect.rs +++ b/src/connect.rs @@ -1185,7 +1185,7 @@ mod verbose { } else if c == b'\0' { write!(f, "\\0")?; // ASCII printable - } else if c >= 0x20 && c < 0x7f { + } else if (0x20..0x7f).contains(&c) { write!(f, "{}", c as char)?; } else { write!(f, "\\x{c:02x}")?; diff --git a/src/into_url.rs b/src/into_url.rs index a46ae5702..5338f2448 100644 --- a/src/into_url.rs +++ b/src/into_url.rs @@ -63,7 +63,7 @@ impl<'a> IntoUrlSealed for &'a String { } } -impl<'a> IntoUrlSealed for String { +impl IntoUrlSealed for String { fn into_url(self) -> crate::Result { (&*self).into_url() } diff --git a/src/proxy.rs b/src/proxy.rs index e4ad3a98c..7d2b1c76a 100644 --- a/src/proxy.rs +++ b/src/proxy.rs @@ -144,14 +144,11 @@ impl IntoProxyScheme for S { let mut source = e.source(); while let Some(err) = source { if let Some(parse_error) = err.downcast_ref::() { - match parse_error { - url::ParseError::RelativeUrlWithoutBase => { - presumed_to_have_scheme = false; - break; - } - _ => {} + if parse_error == url::ParseError::RelativeUrlWithoutBase { + presumed_to_have_scheme = false; + break; } - } else if let Some(_) = err.downcast_ref::() { + } else if err.downcast_ref::().is_some() { presumed_to_have_scheme = false; break; } @@ -657,12 +654,12 @@ impl ProxyScheme { match self { ProxyScheme::Http { ref mut auth, .. } => { if auth.is_none() { - *auth = update.clone(); + auth.clone_from(update); } } ProxyScheme::Https { ref mut auth, .. } => { if auth.is_none() { - *auth = update.clone(); + auth.clone_from(update); } } #[cfg(feature = "socks")] @@ -1029,10 +1026,10 @@ fn get_from_platform() -> Option { #[cfg(any(target_os = "windows", target_os = "macos"))] fn parse_platform_values_impl(platform_values: String) -> SystemProxyMap { let mut proxies = HashMap::new(); - if platform_values.contains("=") { + if platform_values.contains('=') { // per-protocol settings. - for p in platform_values.split(";") { - let protocol_parts: Vec<&str> = p.split("=").collect(); + for p in platform_values.split(';') { + let protocol_parts: Vec<&str> = p.split('=').collect(); match protocol_parts.as_slice() { [protocol, address] => { // If address doesn't specify an explicit protocol as protocol://address @@ -1053,16 +1050,15 @@ fn parse_platform_values_impl(platform_values: String) -> SystemProxyMap { } } } + } else if let Some(scheme) = extract_type_prefix(&platform_values) { + // Explicit protocol has been specified + insert_proxy(&mut proxies, scheme, platform_values.to_owned()); } else { - if let Some(scheme) = extract_type_prefix(&platform_values) { - // Explicit protocol has been specified - insert_proxy(&mut proxies, scheme, platform_values.to_owned()); - } else { - // No explicit protocol has been specified, default to HTTP - insert_proxy(&mut proxies, "http", format!("http://{platform_values}")); - insert_proxy(&mut proxies, "https", format!("http://{platform_values}")); - } + // No explicit protocol has been specified, default to HTTP + insert_proxy(&mut proxies, "http", format!("http://{platform_values}")); + insert_proxy(&mut proxies, "https", format!("http://{platform_values}")); } + proxies } @@ -1850,6 +1846,7 @@ mod test { Proxy::http("ldap%5Cgremlin:pass%3Bword@proxy.example.com:8080").unwrap(); } } + mod and_url_has_bad { use super::super::check_parse_error; @@ -1945,6 +1942,7 @@ mod test { .unwrap(); } } + mod and_url_has_bad { use super::super::check_parse_error;