diff options
| author | Linus Färnstrand <linus@mullvad.net> | 2018-12-03 15:58:09 +0100 |
|---|---|---|
| committer | Linus Färnstrand <linus@mullvad.net> | 2018-12-04 22:43:13 +0100 |
| commit | 5df7286f7e23379dd919b5dd6c783feada9d2b6f (patch) | |
| tree | 0c73e34c92654f28cb2179446e1959262b5177a8 | |
| parent | 2544e7aca021eb062e34eec4d5e6fd4653719766 (diff) | |
| download | mullvadvpn-5df7286f7e23379dd919b5dd6c783feada9d2b6f.tar.xz mullvadvpn-5df7286f7e23379dd919b5dd6c783feada9d2b6f.zip | |
Simplify some iterators in routing, and correct conversion method name
| -rw-r--r-- | talpid-core/src/routing/linux.rs | 7 | ||||
| -rw-r--r-- | talpid-core/src/routing/macos.rs | 2 | ||||
| -rw-r--r-- | talpid-core/src/routing/subprocess.rs | 2 |
3 files changed, 5 insertions, 6 deletions
diff --git a/talpid-core/src/routing/linux.rs b/talpid-core/src/routing/linux.rs index 9f33c9401d..e45c469c57 100644 --- a/talpid-core/src/routing/linux.rs +++ b/talpid-core/src/routing/linux.rs @@ -142,7 +142,7 @@ impl RouteManager { cmd = cmd.arg("table").arg(fwmark); } - cmd.to_expr() + cmd.into_expr() .run_expr() .chain_err(|| ErrorKind::FailedToAddRoute)?; @@ -289,9 +289,8 @@ impl super::RoutingT for RouteManager { let ip_str: &str = output .lines() .find(|line| line.trim().starts_with("default via ")) - .and_then(|line| line.trim().split_whitespace().skip(2).next()) - .map(Ok) - .unwrap_or(Err(Error::from(ErrorKind::FailedToGetDefaultRoute)))?; + .and_then(|line| line.trim().split_whitespace().nth(2)) + .ok_or_else(|| Error::from(ErrorKind::FailedToGetDefaultRoute))?; ip_str .parse() diff --git a/talpid-core/src/routing/macos.rs b/talpid-core/src/routing/macos.rs index 7663ad1bd8..6928084273 100644 --- a/talpid-core/src/routing/macos.rs +++ b/talpid-core/src/routing/macos.rs @@ -50,7 +50,7 @@ impl RouteManager { NetNode::Device(device) => cmd.arg("-interface").arg(&device), }; - cmd.to_expr() + cmd.into_expr() .run_expr() .chain_err(|| ErrorKind::FailedToAddRoute)?; self.set_routes.insert(route); diff --git a/talpid-core/src/routing/subprocess.rs b/talpid-core/src/routing/subprocess.rs index d569f0191b..8b6292c1b4 100644 --- a/talpid-core/src/routing/subprocess.rs +++ b/talpid-core/src/routing/subprocess.rs @@ -40,7 +40,7 @@ impl Exec { self } - pub fn to_expr(self) -> Expression { + pub fn into_expr(self) -> Expression { duct::cmd(self.cmd, self.args) } } |
