blob: 590ffbd9d15ec0357a8b5b2148687f79fde57114 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
use async_stream::stream;
use futures_util::stream::StreamExt;
#[tokio::test]
async fn test() {
let s = stream! {
yield "hello";
yield "world";
};
let s = stream! {
for await x in s {
yield x.to_owned() + "!";
}
};
let values: Vec<_> = s.collect().await;
assert_eq!(2, values.len());
assert_eq!("hello!", values[0]);
assert_eq!("world!", values[1]);
}
|