Skip to content

Commit

Permalink
fix: identifying specific error types
Browse files Browse the repository at this point in the history
  • Loading branch information
jsydliuqing committed Feb 24, 2024
1 parent fcdf337 commit 3ad7cd4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/error.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#[derive(thiserror::Error, Debug)]
#[derive(thiserror::Error, Debug, PartialEq)]
pub enum Error {
/// Returned when `local_ip` is unable to find the system's local IP address
/// in the collection of network interfaces
Expand Down
5 changes: 4 additions & 1 deletion src/linux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,10 @@ fn local_ip_impl(family: RtAddrFamily) -> Result<IpAddr, Error> {

match local_ip_impl_route(family, &mut netlink_socket) {
Ok(ip_addr) => Ok(ip_addr),
Err(_error) => local_ip_impl_addr(family, &mut netlink_socket),
Err(error) if error == Error::LocalIpAddressNotFound => {

Check failure on line 163 in src/linux.rs

View workflow job for this annotation

GitHub Actions / Runs "cargo clippy" on ubuntu-latest

redundant guard
local_ip_impl_addr(family, &mut netlink_socket)
}
Err(e) => Err(e),
}
}

Expand Down

0 comments on commit 3ad7cd4

Please sign in to comment.