You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
433 B
24 lines
433 B
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]);
|
|
}
|