pub struct Sink<A, In, E = (), R = ()>{ /* private fields */ }Expand description
Consumer that reduces a Stream<In, E, R> to a value of type A.
Implementations§
Source§impl<A, In, E, R> Sink<A, In, E, R>
impl<A, In, E, R> Sink<A, In, E, R>
Sourcepub fn fold_left(
init: A,
f: impl Fn(A, In) -> A + Send + Sync + 'static,
) -> Self
pub fn fold_left( init: A, f: impl Fn(A, In) -> A + Send + Sync + 'static, ) -> Self
Left fold over elements (after the stream ends, the accumulator is the result).
Sourcepub fn from_fold(
init: A,
f: impl Fn(A, In) -> A + Send + Sync + 'static,
) -> Self
pub fn from_fold( init: A, f: impl Fn(A, In) -> A + Send + Sync + 'static, ) -> Self
Alias for Self::fold_left.
Sourcepub fn zip<B>(self, other: Sink<B, In, E, R>) -> Sink<(A, B), In, E, R>
pub fn zip<B>(self, other: Sink<B, In, E, R>) -> Sink<(A, B), In, E, R>
Combine two Self::fold_left / Self::from_fold sinks into one pass over the stream.
§Panics
Panics if either sink was not built with Self::fold_left / Self::from_fold.
Source§impl<In, E, R> Sink<Vec<In>, In, E, R>
impl<In, E, R> Sink<Vec<In>, In, E, R>
Sourcepub fn collect_all_while(pred: Predicate<In>) -> Self
pub fn collect_all_while(pred: Predicate<In>) -> Self
Take elements while pred holds; stops before the first failing element (that element is
not included in the result).
Sourcepub fn collect_all_until(pred: Predicate<In>) -> Self
pub fn collect_all_until(pred: Predicate<In>) -> Self
Take elements until pred becomes true; the first matching element is not included.
Trait Implementations§
Auto Trait Implementations§
impl<A, In, E, R> Freeze for Sink<A, In, E, R>
impl<A, In, E = (), R = ()> !RefUnwindSafe for Sink<A, In, E, R>
impl<A, In, E, R> Send for Sink<A, In, E, R>
impl<A, In, E, R> Sync for Sink<A, In, E, R>
impl<A, In, E, R> Unpin for Sink<A, In, E, R>
impl<A, In, E, R> UnsafeUnpin for Sink<A, In, E, R>
impl<A, In, E = (), R = ()> !UnwindSafe for Sink<A, In, E, R>
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