title: Return IAsyncEnumerable from an async method
body: <p>Take the following the methods:</p>
  
  <pre class="lang-cs prettyprint-override"><code>public async IAsyncEnumerable&lt;int&gt; Foo()
  {
     await SomeAsyncMethod();
     return Bar(); // Throws since you can not return values from iterators
  }
  
  public async IAsyncEnumerable&lt;int&gt; Bar()
  {
     for(int i = 0; i &lt; 10; i++)
     {
         await Task.Delay(100);
         yield return i;
     }
  }
  </code></pre>
  
  <p>I wonder what the best practice would be, to do, what the code above tries to. Basically returning an <code>IAsyncEnumerable</code> from an <code>async</code> method.</p>
  
  <p>For myself I can imagine two ways:</p>
  
  <ol>
  <li>Iterating over the <code>IAsyncEnumerable</code> and yielding the result immediately back. </li>
  </ol>
  
  <pre class="lang-cs prettyprint-override"><code>await foreach(var item in Bar())
  {
      yield return item;
  }
  </code></pre>
  
  <ol start="2">
  <li>Creating a struct which can store an <code>IAsyncEnumerable</code> temporarily, which seems to be the better solution, but still kind of overkill. </li>
  </ol>
  
  <pre class="lang-cs prettyprint-override"><code>return new AsyncEnumerableHolder&lt;int&gt;(Bar());
  
  public struct AsyncEnumerableHolder&lt;T&gt;
  {
      public readonly IAsyncEnumerable&lt;T&gt; Enumerable;
  
      public AsyncEnumerableHolder(IAsyncEnumerable&lt;T&gt; enumerable)
      {
          Enumerable = enumerable;
      }
  }
  </code></pre>
  
  <p>Is there any better way to achieve this behavior?</p>