Skip to content

Commit 2323ac9

Browse files
olegnnk-nasa
andauthored
Apply suggestions from code review
Co-authored-by: nasa <htilcs1115@gmail.com>
1 parent 68063ad commit 2323ac9

File tree

2 files changed

+13
-25
lines changed

2 files changed

+13
-25
lines changed

src/stream/stream/flat_map.rs

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -51,22 +51,16 @@ where
5151
let mut this = self.project();
5252
loop {
5353
if let Some(inner) = this.inner_stream.as_mut().as_pin_mut() {
54-
let next_item = futures_core::ready!(inner.poll_next(cx));
55-
56-
if next_item.is_some() {
57-
return Poll::Ready(next_item);
58-
} else {
59-
this.inner_stream.set(None);
54+
match futures_core::ready!(inner.poll_next(cx)) {
55+
item @ Some(_) => return Poll::Ready(item),
56+
None => this.inner_stream.set(None),
6057
}
6158
}
6259

63-
let inner = futures_core::ready!(this.stream.as_mut().poll_next(cx));
64-
65-
if inner.is_some() {
66-
this.inner_stream.set(inner.map(IntoStream::into_stream));
67-
} else {
68-
return Poll::Ready(None);
60+
match futures_core::ready!(this.stream.as_mut().poll_next(cx)) {
61+
inner @ Some(_) => this.inner_stream.set(inner.map(IntoStream::into_stream)),
62+
None => return Poll::Ready(None),
6963
}
7064
}
7165
}
72-
}
66+
}

src/stream/stream/flatten.rs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -52,21 +52,15 @@ where
5252
let mut this = self.project();
5353
loop {
5454
if let Some(inner) = this.inner_stream.as_mut().as_pin_mut() {
55-
let next_item = futures_core::ready!(inner.poll_next(cx));
56-
57-
if next_item.is_some() {
58-
return Poll::Ready(next_item);
59-
} else {
60-
this.inner_stream.set(None);
55+
match futures_core::ready!(inner.poll_next(cx)) {
56+
item @ Some(_) => return Poll::Ready(next_item),
57+
None => this.inner_stream.set(None),
6158
}
6259
}
6360

64-
let inner = futures_core::ready!(this.stream.as_mut().poll_next(cx));
65-
66-
if inner.is_some() {
67-
this.inner_stream.set(inner.map(IntoStream::into_stream));
68-
} else {
69-
return Poll::Ready(None);
61+
match futures_core::ready!(this.stream.as_mut().poll_next(cx)) {
62+
inner @ Some(_) => this.inner_stream.set(inner.map(IntoStream::into_stream)),
63+
None => Poll::Ready(None),
7064
}
7165
}
7266
}

0 commit comments

Comments
 (0)