Skip to content

Instantly share code, notes, and snippets.

@nerdalert
Created December 20, 2019 17:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nerdalert/3a08814036876b3dd0dbced8ca33e47e to your computer and use it in GitHub Desktop.
Save nerdalert/3a08814036876b3dd0dbced8ca33e47e to your computer and use it in GitHub Desktop.
let stream = pinger.and_then(move |pinger| Ok(pinger.chain(ip).stream()));
let future = stream.and_then(|stream| {
stream.take(1).for_each(|mb_time| {
match mb_time {
Some(time) => {
// I need to capture this data (Duration) and get it back to the main scope
println!("Time => {:?}", time);
}
None => println!("timeout"),
}
Ok(())
})
});
tokio::run(future.map_err(|err| eprintln!("Error: {}", err)))
// I need `time` results in this scope
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment