Guest User

Untitled

a guest
Oct 22nd, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. extern crate futures;
  2. extern crate tokio;
  3.  
  4. use futures::{Future, Async};
  5.  
  6. #[derive(Clone)]
  7. pub struct HoldMe{}
  8.  
  9. impl Drop for HoldMe{
  10. fn drop(&mut self) {
  11. panic!("HoldMe is dropped");
  12. }
  13. }
  14.  
  15. struct Never{}
  16. impl Future for Never{
  17. type Item = ();
  18. type Error = ();
  19. fn poll (&mut self) -> Result<Async<()>, ()> {
  20. Ok(Async::NotReady)
  21. }
  22. }
  23.  
  24. pub fn main() {
  25. tokio::run(futures::lazy(move || {
  26. let hold = HoldMe{};
  27. Never{}
  28. .map(move |_|{
  29. println!("dropping now");
  30. drop(hold);
  31. })
  32. }));
  33. }
Add Comment
Please, Sign In to add comment