Skip to content

Commit

Permalink
Replace VecDeque with stream::from_iter in examples (#447)
Browse files Browse the repository at this point in the history
  • Loading branch information
k-nasa authored and Stjepan Glavina committed Nov 3, 2019
1 parent fa91d7f commit ddbbbfc
Show file tree
Hide file tree
Showing 5 changed files with 143 additions and 153 deletions.
6 changes: 2 additions & 4 deletions src/option/sum.rs
Expand Up @@ -20,12 +20,10 @@ where
```
# fn main() { async_std::task::block_on(async {
#
use std::collections::VecDeque;
use async_std::prelude::*;
use async_std::stream;
let words: VecDeque<_> = vec!["have", "a", "great", "day"]
.into_iter()
.collect();
let words = stream::from_iter(vec!["have", "a", "great", "day"]);
let total: Option<usize> = words.map(|w| w.find('a')).sum().await;
assert_eq!(total, Some(5));
#
Expand Down
4 changes: 2 additions & 2 deletions src/result/product.rs
Expand Up @@ -20,10 +20,10 @@ where
```
# fn main() { async_std::task::block_on(async {
#
use std::collections::VecDeque;
use async_std::prelude::*;
use async_std::stream;
let v: VecDeque<_> = vec![1, 2, 4].into_iter().collect();
let v = stream::from_iter(vec![1, 2, 4]);
let res: Result<i32, &'static str> = v.map(|x|
if x < 0 {
Err("Negative element found")
Expand Down
4 changes: 2 additions & 2 deletions src/result/sum.rs
Expand Up @@ -20,10 +20,10 @@ where
```
# fn main() { async_std::task::block_on(async {
#
use std::collections::VecDeque;
use async_std::prelude::*;
use async_std::stream;
let v: VecDeque<_> = vec![1, 2].into_iter().collect();
let v = stream::from_iter(vec![1, 2]);
let res: Result<i32, &'static str> = v.map(|x|
if x < 0 {
Err("Negative element found")
Expand Down
2 changes: 1 addition & 1 deletion src/stream/from_iter.rs
Expand Up @@ -12,7 +12,7 @@ pin_project! {
/// See it documentation for more.
///
/// [`from_iter`]: fn.from_iter.html
#[derive(Debug)]
#[derive(Clone, Debug)]
pub struct FromIter<I> {
iter: I,
}
Expand Down

0 comments on commit ddbbbfc

Please sign in to comment.