tokio: simplify Option handling with idiomatic combinators (#8336)

This commit is contained in:
Tim Vilgot Mikael Fredenberg
2026-08-07 21:18:39 +08:00
committed by GitHub
parent dd344a550c
commit cc8c053421
17 changed files with 30 additions and 51 deletions
+1 -1
View File
@@ -1040,7 +1040,7 @@ impl Builder {
fn num_head_bytes(&self) -> usize {
let num = self.length_field_offset + self.length_field_len;
cmp::max(num, self.num_skip.unwrap_or(0))
cmp::max(num, self.num_skip.unwrap_or_default())
}
fn get_num_skip(&self) -> usize {
+1 -6
View File
@@ -580,12 +580,7 @@ impl<T> DelayQueue<T> {
/// current task for wakeup if the value is not yet available, and returning
/// `None` if the queue is exhausted.
pub fn poll_expired(&mut self, cx: &mut task::Context<'_>) -> Poll<Option<Expired<T>>> {
if !self
.waker
.as_ref()
.map(|w| w.will_wake(cx.waker()))
.unwrap_or(false)
{
if !self.waker.as_ref().is_some_and(|w| w.will_wake(cx.waker())) {
self.waker = Some(cx.waker().clone());
}
+1 -2
View File
@@ -111,8 +111,7 @@ where
debug_assert!({
self.levels[level]
.next_expiration(self.elapsed)
.map(|e| e.deadline >= self.elapsed)
.unwrap_or(true)
.map_or(true, |e| e.deadline >= self.elapsed)
});
Ok(())