pub struct Stream<E, A> { /* private fields */ }Expand description
An effectful stream producing values of type A.
Pull-based: each step is an Io that produces either
the next value and the rest of the stream, or None.
Implementations§
Source§impl<E: Send + 'static, A: Send + 'static> Stream<E, A>
impl<E: Send + 'static, A: Send + 'static> Stream<E, A>
Sourcepub fn unfold<S: Send + 'static>(
init: S,
step: Arc<dyn Fn(S) -> Io<E, Option<(A, S)>> + Send + Sync>,
) -> Self
pub fn unfold<S: Send + 'static>( init: S, step: Arc<dyn Fn(S) -> Io<E, Option<(A, S)>> + Send + Sync>, ) -> Self
Build a stream by repeatedly applying a step function to state.
The step function returns None to end the stream, or
Some((value, next_state)) to emit and continue.
Sourcepub fn map<B: Send + 'static>(
self,
f: Arc<dyn Fn(A) -> B + Send + Sync>,
) -> Stream<E, B>
pub fn map<B: Send + 'static>( self, f: Arc<dyn Fn(A) -> B + Send + Sync>, ) -> Stream<E, B>
Apply a function to each element.
Auto Trait Implementations§
impl<E, A> Freeze for Stream<E, A>
impl<E, A> !RefUnwindSafe for Stream<E, A>
impl<E, A> Send for Stream<E, A>
impl<E, A> !Sync for Stream<E, A>
impl<E, A> Unpin for Stream<E, A>
impl<E, A> UnsafeUnpin for Stream<E, A>
impl<E, A> !UnwindSafe for Stream<E, A>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more