title: How to await a Rust Future on a non-async function
body: <p>Rust newbie here (&lt;7 days into learning), the second hurdle I am trying to overcome after ownership rule is async/await.</p>
  
  <p>I am writing a test that calls an <code>async</code> function and I need to get the result from the <code>Future</code> without using the keyword <code>await</code>.</p>
  
  <p>I have looked at <code>async_test</code>, however I can't use that because (as I understand) this requires <code>tokio</code> runtime and <code>#[tokio_main]</code> attribute in my <code>main</code> method - but I have my <code>main</code> already decorated with <code>#[actix_rt::main]</code></p>
  
  <p>This is my test</p>
  
  <pre class="lang-rust prettyprint-override"><code>#[test]
  pub fn test_get_item() -&gt; Result&lt;(), anyhow::Error&gt; {
      let c = SomeClient::new();
      let result = c.get_item(123456).await?; // &lt;- this is not allowed
  
      assert_eq!("Hello", result.title);
      assert_eq!("https://example.com", result.url.as_str());
  
      Ok(())
  }
  
  </code></pre>
  
  <p>Things I have tried and failed (mostly due to my lack of knowledge in Rust)</p>
  
  <ul>
  <li>Use <code>async_test</code> on an actix web project using <a href="https://github.com/ngg/futures-await-test/blob/master/futures-await-test/tests/test.rs" rel="nofollow noreferrer">futures-await-test</a> crate.</li>
  <li>Read this <a href="https://www.reddit.com/r/rust/comments/7ku3f0/using_futures_in_non_async_code/" rel="nofollow noreferrer">thread</a> in reddit.</li>
  <li>Follow few examples from this <a href="https://users.rust-lang.org/t/how-to-wait-an-async-in-non-async-function/28388/12" rel="nofollow noreferrer">rust community thread</a></li>
  <li>Tried to <code>poll()</code> the future but it didn't lead me anywhere.</li>
  </ul>
  
  <p>I don't understand why this has to be so complicated, maybe there is a simple function (like <code>wait()</code> or <code>get_result()</code>) somewhere for <code>Future</code>?</p>
  
  <p>Thanks for your help.</p>