title: What is futures::future::lazy for?
body: <p>In the <a href="https://tokio.rs/docs/futures/spawning/" rel="nofollow noreferrer">Tokio documentation</a> we have this snippet:</p>
  
  <pre class="lang-rust prettyprint-override"><code>extern crate tokio;
  extern crate futures;
  
  use futures::future::lazy;
  
  tokio::run(lazy(|| {
      for i in 0..4 {
          tokio::spawn(lazy(move || {
              println!("Hello from task {}", i);
              Ok(())
          }));
      }
  
      Ok(())
  }));
  </code></pre>
  
  <p>The explanation for this is:</p>
  
  <blockquote>
    <p>The <code>lazy</code> function runs the closure the first time the future is polled. It is used here to ensure that <code>tokio::spawn</code> is called from a task. Without <code>lazy</code>, <code>tokio::spawn</code> would be called from outside the context of a task, which results in an error.</p>
  </blockquote>
  
  <p>I'm not sure I understand this precisely, despite having some familiarity with Tokio. It seems that these two <code>lazy</code> have slightly different roles, and that this explanation only applies to the <em>first</em> one. Isn't the second call to <code>lazy</code> (inside the <code>for</code> loop) just here to convert the closure into a future?</p>