Skip to content

Commit eefc507

Browse files
committed
refactor: use if let Err instead of match
1 parent 81e87ee commit eefc507

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

crates/net/p2p/src/req_resp/codec.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,10 +215,11 @@ where
215215
loop {
216216
// Read chunk result code
217217
let mut result_byte = 0_u8;
218-
match io.read_exact(std::slice::from_mut(&mut result_byte)).await {
219-
Ok(()) => {}
220-
Err(e) if e.kind() == io::ErrorKind::UnexpectedEof => break,
221-
Err(e) => return Err(e),
218+
if let Err(e) = io.read_exact(std::slice::from_mut(&mut result_byte)).await {
219+
if e.kind() == io::ErrorKind::UnexpectedEof {
220+
break;
221+
}
222+
return Err(e);
222223
}
223224

224225
let code = ResponseCode::from(result_byte);

0 commit comments

Comments
 (0)