mirror of
https://github.com/async-rs/async-std.git
synced 2025-03-05 17:49:40 +00:00
Document from_iter for DoubleEndedStream
This commit is contained in:
parent
892c6008c2
commit
6e8236d0e1
1 changed files with 19 additions and 0 deletions
|
@ -15,6 +15,25 @@ pub struct FromIter<T> {
|
||||||
inner: Vec<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> {
|
pub fn from_iter<I: IntoIterator>(iter: I) -> FromIter<I::Item> {
|
||||||
FromIter { inner: iter.into_iter().collect() }
|
FromIter { inner: iter.into_iter().collect() }
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue