Skip to content

Commit

Permalink
refactor(core): simplify common::process_result
Browse files Browse the repository at this point in the history
  • Loading branch information
fujiapple852 committed Jul 30, 2024
1 parent 8c96bf1 commit 6d4473b
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions crates/trippy-core/src/net/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,11 @@ use std::net::SocketAddr;
pub fn process_result(addr: SocketAddr, res: IoResult<()>) -> Result<()> {
match res {
Ok(()) => Ok(()),
Err(err) => {
if err.kind() == ErrorKind::InProgress {
Ok(())
} else {
match err.kind() {
ErrorKind::Std(io::ErrorKind::AddrInUse) => Err(Error::AddressInUse(addr)),
_ => Err(Error::IoError(err)),
}
}
}
Err(err) => match err.kind() {
ErrorKind::InProgress => Ok(()),
ErrorKind::Std(io::ErrorKind::AddrInUse) => Err(Error::AddressInUse(addr)),
ErrorKind::Std(_) => Err(Error::IoError(err)),
},
}
}

Expand Down

0 comments on commit 6d4473b

Please sign in to comment.