Skip to content

Commit

Permalink
Improve code readability and quality by:
Browse files Browse the repository at this point in the history
1. Use of range operator for comparison
2. Use of collapsible_match
  • Loading branch information
bishtpawan committed Mar 11, 2021
1 parent c666b29 commit ef89151
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/connect.rs
Expand Up @@ -1005,7 +1005,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{:02x}", c)?;
Expand Down
12 changes: 4 additions & 8 deletions src/proxy.rs
Expand Up @@ -279,11 +279,8 @@ impl Proxy {
// Custom *may* match 'http', so assume so.
| Intercept::Custom(_) => true,
Intercept::System(ref system) => {
if let Some(proxy) = system.get("http") {
match proxy {
ProxyScheme::Http { auth, .. } => auth.is_some(),
_ => false,
}
if let Some(ProxyScheme::Http { auth, .. }) = system.get("http") {
auth.is_some()
} else {
false
}
Expand Down Expand Up @@ -732,19 +729,18 @@ fn get_sys_proxies(
RegistryProxyValues,
>,
) -> SystemProxyMap {
let proxies = get_from_environment();

// TODO: move the following #[cfg] to `if expression` when attributes on `if` expressions allowed
#[cfg(target_os = "windows")]
{
let proxies = get_from_environment();
if proxies.is_empty() {
// don't care errors if can't get proxies from registry, just return an empty HashMap.
if let Some(registry_values) = registry_values {
return parse_registry_values(registry_values);
}
}
}
proxies
get_from_environment()
}

fn insert_proxy(proxies: &mut SystemProxyMap, scheme: impl Into<String>, addr: String) -> bool {
Expand Down

0 comments on commit ef89151

Please sign in to comment.