mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-09-08 00:00:13 +02:00
tokio: simplify Option handling with idiomatic combinators (#8336)
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
|
||||
@@ -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(())
|
||||
|
||||
Reference in New Issue
Block a user