Skip to content

Commit 8c92ba3

Browse files
authored
util: Simplify timeout error handling in Buffer (#708)
Refactor the timeout error handling in `util/src/buffer/mod.rs` to use the `?` operator. This change simplifies the code by using `map_err` to convert the timeout error to `Error::ErrTimeout`, which is more concise and idiomatic. Signed-off-by: Xiaobo Liu <[email protected]>
1 parent a91689c commit 8c92ba3

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

util/src/buffer/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -254,9 +254,9 @@ impl Buffer {
254254

255255
// Wait for signal.
256256
if let Some(d) = duration {
257-
if timeout(d, self.notify.notified()).await.is_err() {
258-
return Err(Error::ErrTimeout);
259-
}
257+
timeout(d, self.notify.notified())
258+
.await
259+
.map_err(|_| Error::ErrTimeout)?;
260260
} else {
261261
self.notify.notified().await;
262262
}

0 commit comments

Comments
 (0)