Skip to content

Commit 49d123c

Browse files
committed
Fix review nits
1 parent 2384df1 commit 49d123c

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/stream/repeat_with.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,11 @@ pub struct RepeatWith<F, Fut, A> {
5757
/// assert_eq!(s.next().await, None);
5858
/// # }) }
5959
/// ```
60-
pub fn repeat_with<F, Fut, A>(repeater: F) -> RepeatWith<F, Fut, A> {
60+
pub fn repeat_with<F, Fut, A>(repeater: F) -> RepeatWith<F, Fut, A>
61+
where
62+
F: FnMut() -> Fut,
63+
Fut: Future<Output = A>,
64+
{
6165
RepeatWith {
6266
f: repeater,
6367
future: None,
@@ -79,16 +83,16 @@ where
7983

8084
fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
8185
loop {
82-
match self.future.is_some() {
83-
true => {
86+
match &self.future {
87+
Some(_) => {
8488
let res =
8589
futures_core::ready!(self.as_mut().future().as_pin_mut().unwrap().poll(cx));
8690

8791
self.as_mut().future().set(None);
8892

8993
return Poll::Ready(Some(res));
9094
}
91-
false => {
95+
None => {
9296
let fut = (self.as_mut().f())();
9397

9498
self.as_mut().future().set(Some(fut));

0 commit comments

Comments
 (0)