Skip to content

Instantly share code, notes, and snippets.

@saethlin
Created February 22, 2018 01:32
Show Gist options
  • Save saethlin/fb5dddc657fe03188e22c07ea2fea143 to your computer and use it in GitHub Desktop.
Save saethlin/fb5dddc657fe03188e22c07ea2fea143 to your computer and use it in GitHub Desktop.
extern crate futures;
extern crate tokio;
use futures::future::lazy;
use tokio::executor::current_thread;
fn main() {
let data = vec![1, 2, 3, 4, 5];
current_thread::run(move |_| {
for num in data.iter() {
current_thread::spawn(lazy(move || {
println!("printing {}", num);
Ok(())
}));
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment