title: How can I get a Span<T> from a List<T> while avoiding needless copies?
body: <p>I have a <code>List&lt;T&gt;</code> containing some data. I would like to pass it to a function which accepts <code>ReadOnlySpan&lt;T&gt;</code>.</p>
  
  <pre><code>List&lt;T&gt; items = GetListOfItems();
  // ...
  void Consume&lt;T&gt;(ReadOnlySpan&lt;T&gt; buffer)
  // ...
  Consume(items??);
  </code></pre>
  
  <p>In this particular instance T is <code>byte</code> but it doesn't really matter.</p>
  
  <p>I know I can use <code>.ToArray()</code> on the List, and the construct a span, e.g.</p>
  
  <pre><code>Consume(new ReadOnlySpan&lt;T&gt;(items.ToArray()));
  </code></pre>
  
  <p>However this creates a (seemingly) unneccessary copy of the items. Is there any way to get a Span directly from a List? <code>List&lt;T&gt;</code> is implemented in terms of <code>T[]</code> behind the scenes, so in theory it's possible, but not as far as I can see in practice?</p>