iter

Function iter 

Source
pub fn iter<I, O>(i: I) -> impl Stream<Item = Result<O, AnyError>>
where I: IntoIterator<Item = O>,
Expand description

Create a stream of Result<T, AnyError> from an iterator of type T.

This is a convenience function for creating a Result/TryStream from an iterator of Ok values.

ยงExample


let mut stream = iter(vec![1, 2, 3]);
assert_eq!(stream.next().await, Some(Ok(1)));
assert_eq!(stream.next().await, Some(Ok(2)));
assert_eq!(stream.next().await, Some(Ok(3)));
assert_eq!(stream.next().await, None);