Skip to content

Commit 6e8236d

Browse files
committed
Document from_iter for DoubleEndedStream
1 parent 892c600 commit 6e8236d

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/stream/double_ended/from_iter.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,25 @@ pub struct FromIter<T> {
1515
inner: Vec<T>,
1616
}
1717

18+
/// Converts an iterator into a double-ended stream.
19+
///
20+
/// # Examples
21+
///
22+
/// ```
23+
/// # async_std::task::block_on(async {
24+
/// #
25+
/// use async_std::stream::double_ended::{self, DoubleEndedStreamExt};
26+
///
27+
/// let mut s = double_ended::from_iter(vec![0, 1, 2, 3]);
28+
///
29+
/// assert_eq!(s.next_back().await, Some(3));
30+
/// assert_eq!(s.next_back().await, Some(2));
31+
/// assert_eq!(s.next_back().await, Some(1));
32+
/// assert_eq!(s.next_back().await, Some(0));
33+
/// assert_eq!(s.next_back().await, None);
34+
/// #
35+
/// # })
36+
/// ```
1837
pub fn from_iter<I: IntoIterator>(iter: I) -> FromIter<I::Item> {
1938
FromIter { inner: iter.into_iter().collect() }
2039
}

0 commit comments

Comments
 (0)