title: How to call an async function in poll() method?
body: <p>I want to call async function in Future::poll(), but the poll() is not async function, so I have to poll the async fn, but got error:</p>
  <pre class="lang-none prettyprint-override"><code>error[E0599]: no method named `poll` found for opaque type `impl Future` in the current scope
    --&gt; src\lib.rs:18:22
     |
  18 |         let a = fut1.poll(cx);
     |                      ^^^^ method not found in `impl Future`
  </code></pre>
  <p>I try to Pin::new(async fn()).poll(), got another error:</p>
  <pre class="lang-none prettyprint-override"><code>error[E0277]: `from_generator::GenFuture&lt;[static generator@src\lib.rs:33:23: 36:2 {ResumeTy, u64, Duration, impl Future, ()}]&gt;` cannot be unpinned
    --&gt; src\lib.rs:22:23
     |
  22 |         let pinfut1 = Pin::new(&amp;mut fut1);
     |                       ^^^^^^^^ within `impl Future`, the trait `Unpin` is not implemented for `from_generator::GenFuture&lt;[static generator@src\lib.rs:33:23: 36:2 {ResumeTy, u64, Duration, impl Future, ()}]&gt;`
  ...
  33 | async fn fn1() -&gt; i32 {
     |                   --- within this `impl Future`
  </code></pre>
  <p>code:</p>
  <pre><code>use std::future::Future;
  use std::task::{Context, Poll};
  use std::pin::Pin;
  use std::sync::{Arc,Mutex};
  
  #[pin_project::pin_project]
  struct Person&lt;'a&gt; {
      name: &amp;'a str,
      age: i32,
  }
  
  impl&lt;'a&gt; Future for Person&lt;'a&gt; {
      type Output = i32;
  
      fn poll(self: Pin&lt;&amp;mut Self&gt;, cx: &amp;mut Context&lt;'_&gt;) -&gt; Poll&lt;Self::Output&gt; {
          let mut this = self.project();
          *this.age += 1;
  
          // error: poll() ^^^^ method not found in `impl Future`
          // let mut fut1 = fn1();
          // let a = fut1.poll(cx);
  
          // error: Pin::new() ^^^^^^^^ within `impl Future`, the trait `Unpin` is not implemented for `from_generator::GenFuture
          let mut fut1 = fn1();
          let pinfut1 = Pin::new(&amp;mut fut1);
          let a = pinfut1.poll(cx);
  
          if *this.age &gt; 4 {
              Poll::Ready(*this.age)
          } else {
              Poll::Pending
          }
      }
  }
  
  async fn fn1() -&gt; i32 {
      async_std::task::sleep(std::time::Duration::from_secs(2)).await;
      123
  }
  
  fn main() {
      let p1 = Person {name: &quot;jack&quot;, age: Default::default()};
      async_std::task::block_on(async {
          let a = p1.await;
          dbg!(a);
      });
  }
  </code></pre>