use futures_util::stream::StreamExt;
use rs2_stream::rs2::*;
use tokio::runtime::Runtime;
fn main() {
let rt = Runtime::new().unwrap();
rt.block_on(async {
let notification = "New message!";
let notification_stream = repeat(notification).take(3);
let notifications = notification_stream.collect::<Vec<_>>().await;
println!("Notifications: {:?}", notifications);
let user_id_stream = unfold(
1, |id| async move {
if id <= 5 {
Some((id, id + 1))
} else {
None }
},
);
let user_ids = user_id_stream.collect::<Vec<_>>().await;
println!("User IDs: {:?}", user_ids); });
}