diff --git a/src/stream/mod.rs b/src/stream/mod.rs index f410e08..bab9dc7 100644 --- a/src/stream/mod.rs +++ b/src/stream/mod.rs @@ -308,6 +308,7 @@ pub use once::{once, Once}; pub use repeat::{repeat, Repeat}; pub use repeat_with::{repeat_with, RepeatWith}; pub use stream::*; +pub use successor::{successor, Successor}; pub(crate) mod stream; diff --git a/src/stream/successor.rs b/src/stream/successor.rs index 3ddeef4..8e93956 100644 --- a/src/stream/successor.rs +++ b/src/stream/successor.rs @@ -1,5 +1,5 @@ -use std::pin::Pin; use std::marker::PhantomData; +use std::pin::Pin; use crate::future::Future; use crate::stream::Stream; @@ -12,13 +12,14 @@ use crate::task::{Context, Poll}; /// /// [`successor`]: fn.successor.html #[derive(Debug)] -pub struct Successor -where Fut: Future +pub struct Successor +where + Fut: Future, { successor: F, future: Option, next: T, - _marker: PhantomData + _marker: PhantomData, } /// Creates a new stream where to produce each new element a clousre is called with the previous @@ -51,29 +52,27 @@ where F: FnMut(T) -> Fut, Fut: Future, T: Copy, - { - Successor { - successor: func, - future: None, - next: start, - _marker: PhantomData, - } +{ + Successor { + successor: func, + future: None, + next: start, + _marker: PhantomData, } +} -impl Successor +impl Successor where F: FnMut(T) -> Fut, Fut: Future, T: Copy, - { pin_utils::unsafe_unpinned!(successor: F); pin_utils::unsafe_unpinned!(next: T); pin_utils::unsafe_pinned!(future: Option); - } -impl Stream for Successor +impl Stream for Successor where Fut: Future, F: FnMut(T) -> Fut, @@ -88,7 +87,7 @@ where let fut = (self.as_mut().successor())(x); self.as_mut().future().set(Some(fut)); } - _ => {}, + _ => {} } let next = futures_core::ready!(self.as_mut().future().as_pin_mut().unwrap().poll(cx)); @@ -97,4 +96,3 @@ where Poll::Ready(Some(next)) } } -