Document from_iter for DoubleEndedStream

split-by-pattern
Felipe Sere 5 years ago
parent 892c6008c2
commit 6e8236d0e1

@ -15,6 +15,25 @@ pub struct FromIter<T> {
inner: Vec<T>,
}
/// Converts an iterator into a double-ended stream.
///
/// # Examples
///
/// ```
/// # async_std::task::block_on(async {
/// #
/// use async_std::stream::double_ended::{self, DoubleEndedStreamExt};
///
/// let mut s = double_ended::from_iter(vec![0, 1, 2, 3]);
///
/// assert_eq!(s.next_back().await, Some(3));
/// assert_eq!(s.next_back().await, Some(2));
/// assert_eq!(s.next_back().await, Some(1));
/// assert_eq!(s.next_back().await, Some(0));
/// assert_eq!(s.next_back().await, None);
/// #
/// # })
/// ```
pub fn from_iter<I: IntoIterator>(iter: I) -> FromIter<I::Item> {
FromIter { inner: iter.into_iter().collect() }
}

Loading…
Cancel
Save