Signed-off-by: Yoshua Wuyts <yoshuawuyts@gmail.com>
split-by-pattern
Yoshua Wuyts 5 years ago
parent 019aa14898
commit 8ad1d23116
No known key found for this signature in database
GPG Key ID: 24EA8164F96777ED

@ -105,9 +105,10 @@ pub trait DoubleEndedStream: Stream {
```
# fn main() { async_std::task::block_on(async {
#
use async_std::stream::double_ended_stream::{self, DoubleEndedStream};
use async_std::prelude::*;
use async_std::stream;
let mut s = double_ended_stream::from_iter(vec![7u8]);
let mut s = stream::from_iter(vec![7u8]);
assert_eq!(s.next_back().await, Some(7));
assert_eq!(s.next_back().await, None);
@ -132,9 +133,10 @@ pub trait DoubleEndedStream: Stream {
```
# fn main() { async_std::task::block_on(async {
#
use async_std::stream::double_ended_stream::{self, DoubleEndedStream};
use async_std::prelude::*;
use async_std::stream;
let mut s = double_ended_stream::from_iter(vec![1u8, 2, 3, 4, 5]);
let mut s = stream::from_iter(vec![1u8, 2, 3, 4, 5]);
let second = s.nth_back(1).await;
assert_eq!(second, Some(4));
@ -159,9 +161,10 @@ pub trait DoubleEndedStream: Stream {
```
# fn main() { async_std::task::block_on(async {
#
use async_std::stream::double_ended_stream::{self, DoubleEndedStream};
use async_std::prelude::*;
use async_std::stream;
let mut s = double_ended_stream::from_iter(vec![1u8, 2, 3, 4, 5]);
let mut s = stream::from_iter(vec![1u8, 2, 3, 4, 5]);
let second = s.rfind(|v| v % 2 == 0).await;
assert_eq!(second, Some(4));
@ -185,9 +188,10 @@ pub trait DoubleEndedStream: Stream {
```
# fn main() { async_std::task::block_on(async {
#
use async_std::stream::double_ended_stream::{self, DoubleEndedStream};
use async_std::prelude::*;
use async_std::stream;
let s = double_ended_stream::from_iter(vec![1u8, 2, 3, 4, 5]);
let s = stream::from_iter(vec![1u8, 2, 3, 4, 5]);
let second = s.rfold(0, |acc, v| v + acc).await;
@ -215,9 +219,10 @@ pub trait DoubleEndedStream: Stream {
```
# fn main() { async_std::task::block_on(async {
#
use async_std::stream::double_ended_stream::{self, DoubleEndedStream};
use async_std::prelude::*;
use async_std::stream;
let s = double_ended_stream::from_iter(vec![1u8, 2, 3, 4, 5]);
let s = stream::from_iter(vec![1u8, 2, 3, 4, 5]);
let sum = s.try_rfold(0, |acc, v| {
if (acc+v) % 2 == 1 {
Ok(v+3)

Loading…
Cancel
Save