mirror of
https://github.com/async-rs/async-std.git
synced 2025-04-25 17:56:49 +00:00
Fix review nits
This commit is contained in:
parent
2384df11ed
commit
49d123c7f9
1 changed files with 8 additions and 4 deletions
|
@ -57,7 +57,11 @@ pub struct RepeatWith<F, Fut, A> {
|
||||||
/// assert_eq!(s.next().await, None);
|
/// assert_eq!(s.next().await, None);
|
||||||
/// # }) }
|
/// # }) }
|
||||||
/// ```
|
/// ```
|
||||||
pub fn repeat_with<F, Fut, A>(repeater: F) -> RepeatWith<F, Fut, A> {
|
pub fn repeat_with<F, Fut, A>(repeater: F) -> RepeatWith<F, Fut, A>
|
||||||
|
where
|
||||||
|
F: FnMut() -> Fut,
|
||||||
|
Fut: Future<Output = A>,
|
||||||
|
{
|
||||||
RepeatWith {
|
RepeatWith {
|
||||||
f: repeater,
|
f: repeater,
|
||||||
future: None,
|
future: None,
|
||||||
|
@ -79,8 +83,8 @@ where
|
||||||
|
|
||||||
fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
|
fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
|
||||||
loop {
|
loop {
|
||||||
match self.future.is_some() {
|
match &self.future {
|
||||||
true => {
|
Some(_) => {
|
||||||
let res =
|
let res =
|
||||||
futures_core::ready!(self.as_mut().future().as_pin_mut().unwrap().poll(cx));
|
futures_core::ready!(self.as_mut().future().as_pin_mut().unwrap().poll(cx));
|
||||||
|
|
||||||
|
@ -88,7 +92,7 @@ where
|
||||||
|
|
||||||
return Poll::Ready(Some(res));
|
return Poll::Ready(Some(res));
|
||||||
}
|
}
|
||||||
false => {
|
None => {
|
||||||
let fut = (self.as_mut().f())();
|
let fut = (self.as_mut().f())();
|
||||||
|
|
||||||
self.as_mut().future().set(Some(fut));
|
self.as_mut().future().set(Some(fut));
|
||||||
|
|
Loading…
Reference in a new issue